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参数类型 形参:定义函数时的参数变量. 实参:调用函数时使用的参数变量. 参数传递的过程 ...
随机推荐
- Python源码分析之dis
一.简单例子 def add(a, b): return a + b add_nums.py import foo a = [1, 'python'] a = 'a string' def func( ...
- Oracle按时间段分组统计
想要按时间段分组查询,首先要了解level,connect by,oracle时间的加减. 关于level这里不多说,我只写出一个查询语句: ----level 是一个伪例 ---结果: 关于conn ...
- Java常用基础代码
1.加载properties文件 Properties properties = new Properties(); properties.load(Properties.class.getReso ...
- QQ空间点赞代码
jQuery("a.qz_like_btn_v3[data-clicklog='like']").each(function(index,item){ console.log(it ...
- 蚂蚁金服 Service Mesh 实践探索
SOFAMesh是蚂蚁金服在ServiceMesh方向上的探索,下面是它高级技术专家敖小剑在QCon上海2018上的演讲. Service Mesh 是一个 基础设施层,用于处理服务间通讯.现代云原生 ...
- DNS记录类型名单
原文:http://www.worldlingo.com/ma/enwiki/zh_cn/List_of_DNS_record_types DNS记录类型名单 这 DNS记录类型名单 提供一个方便索引 ...
- coding github 配置ssl 免密拉取代码
详细介绍: https://www.cnblogs.com/superGG1990/p/6844952.html 注:其中检验过程与下述不同,可以先在对应git库使用 git pull 一次,选择信任 ...
- ajax readyState=4并且status=200时,还进error方法
今天在使用jQuery.ajax方法去调用后台方法时,ajax中得参数data类型是"JSON",后台DEBUG调试,运行正常, 返回正常的结果集,但是前端一直都进到ajax的er ...
- 解决php收邮件乱码问题
function test($strHead){ if(ereg("=\?.{0,}\?[Bb]\?",$strHead)){ $arrHead=split("=\?.{ ...
- urllib2异常处理(七)
urllib2 的异常错误处理 在我们用urlopen或opener.open方法发出一个请求时,如果urlopen或opener.open不能处理这个response,就产生错误. 这里主要说的是U ...