python参数Sample Code
import time
import datetime
import getopt
import sys
try:
opts, args = getopt.getopt(sys.argv[1:], "ho:", ["inputOCR=", "inputSpeech="])
except getopt.GetoptError:
print ('Getopt Error!')
sys.exit(1)
for name, value in opts:
if name in ("-o"):
outPath = value
print(outPath)
elif name in ("--inputOCR"):
inputOCRPath = value
print(inputOCRPath)
elif name in ("--inputSpeech"):
inputSpeechPath = value
print(inputSpeechPath)
## cut contents to three parts[begin time] [end time] [txt]
def SplitFStr(strT):
mm = []
strT = strT[1:] #cut out str first char to end
mm = strT.split(']', 2)
listN = mm[0].split('-', 2)
listN.append(mm[1])
return listN
def mapper(line):
pos = line.find(']')
return "%s%s%s" % (line[0:pos+1], '[OCR]', line[pos+1:])
try:
ListContents = []
file = open(inputSpeechPath, 'r+')
ListContents = file.readlines()
file.close()
file = open(inputOCRPath, 'r+')
ListContentOCR = file.readlines()
file.close()
for item in ListContentOCR:
itemT = mapper(item)
ListContents.append(itemT)
ListTotal = []
for litem in ListContents:
listC = SplitFStr(litem)
t1 = time.strptime(listC[0], "%H:%M:%S")
dictE = {'time':t1, 'txt':litem}
ListTotal.append(dictE)
def TimeSort(t):
return t['time']
ListSort = sorted(ListTotal, key = TimeSort)
fp = open(outPath, 'w+')
for lsitem in ListSort:
fp.write(lsitem['txt'])
fp.close()
except IOError as err:
print('File IO error: ' + str(err))
python参数Sample Code的更多相关文章
- 如何将经纬度利用Google Map API显示C# VS2005 Sample Code
原文 如何将经纬度利用Google Map API显示C# VS2005 Sample Code 日前写了一篇如何用GPS抓取目前所在,并回传至资料库储存,这篇将会利用这些回报的资料,将它显示在地图上 ...
- Sample Code之Web scene-slides
这是我的第一篇随笔,在开始正文前说几句. 这个系列会记录我学习Arcgis js API 4.10的全过程,希望能对自己也对其他有需要的人有帮助.很多时候上网看一些大神的帖子会感到一头雾水,一是自己水 ...
- android studio2.2 的Find Sample Code点击没有反应
1 . 出现的问题描述: 右键点击Find Sample Code后半天没有反应,然后提示 Samples are currently unavailable for :{**** ...
- IOS开发苹果官方Sample Code及下载地址
IOS开发苹果官方Sample Code及下载地址 在线浏览地址:https://developer.apple.com/library/ios/navigation/#section=Resourc ...
- Python参数笔记
Python参数 1. 普通参数 必须要传入和定义时个数相同的参数 def miao(acfun, bilibili): print(acfun, bilibili) miao(11, 22) > ...
- Converting Python Virtual Machine Code to C
Converting Python Virtual Machine Code to C
- OAF Sample Code(转)
原文地址: OAF Sample Code
- Python参数基础
Python参数基础 位置参数 通过位置进行匹配,把参数值传递给函数头部的参数名称,顺序从左到右 关键字参数 调用的时候使用参数的变量名,采用name=value的形式 默认参数 为没有传 ...
- Python参数类型以及实现isOdd函数,isNum函数,multi函数,isPrime函数
Python参数类型以及实现isOdd函数,isNum函数,multi函数,isPrime函数 一.Python参数类型 形参:定义函数时的参数变量. 实参:调用函数时使用的参数变量. 参数传递的过程 ...
随机推荐
- WindowsXamlHost:在 WPF 中使用 UWP 的控件(Windows Community Toolkit)
Windows Community Toolkit 再次更新到 5.0.以前可以在 WPF 中使用有限的 UWP 控件,而现在有了 WindowsXamlHost,则可以使用更多 UWP 原生控件了. ...
- streamsets microservice pipeline 试用
实际上还是一个pipeline,只是添加了一些规则以及内嵌的http server 方便我们对于基于http 或者类似轻量 协议数据的处理 基本环境 使用docker&& docker ...
- deno学习二 基本代码
deno 介绍是安全的ts 运行时 简单的代码 使用js(app.js) console.log("demoapp") 输出 dalongdemo 使用ts(app.ts) con ...
- 机器学习 ----Tensorflow
机器学习笔记4-Tensorflow线性模型示例及TensorBoard的使用 机器学习笔记3-Tensorflow简介 机器学习笔记2 – sklearn之iris数据集 机器学习笔记1 - Hel ...
- cocos2dx Scene,Layer,Sprite的理解
layer,scene,sprite的默认锚点都是0.5,0.5 三者都继承自Node节点,暂时没看出有什么区别,或者下面的话是对的吧. 在cocos2d-x中,一个应用可以有多个scene,但任何时 ...
- web应用中的Filter过滤器之基础概述
1 过滤器概述 当web容器接收到对一个资源的请求时,它将判断是否有过滤器与这个资源相关联,如果有,那么容器将把这个请求交给过滤器进行处理.在过滤器中,你可以改变请求的内容或者重新设置请求的报头信息, ...
- POJ1236学校网络——tarjan
题目:http://poj.org/problem?id=1236 Tarjan+缩点.温习一下Tarjan的写法. 1.在缩点后的TAG中,有几个联通块等价于有几个入度为0的点! 2.把它们都联通相 ...
- erlang单独配置文件
一种是erl启动的时候加参数 doudizhu.config [ {doudizhu,[ {listen_port, }, {node_caller_prefix,"ruby"}, ...
- Bootstrap-CL:面包屑导航
ylbtech-Bootstrap-CL:面包屑导航 1.返回顶部 1. Bootstrap 面包屑导航(Breadcrumbs) 面包屑导航(Breadcrumbs)是一种基于网站层次信息的显示方式 ...
- 【ZZ】国外大型网站使用到编程语言 | 菜鸟教程
http://www.runoob.com/w3cnote/rogramming-languages-used-in-most-popular-websites.html 下图展示了大型网站使用到的后 ...