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参数类型 形参:定义函数时的参数变量. 实参:调用函数时使用的参数变量. 参数传递的过程 ...
随机推荐
- 7-17 Hashing(25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash tabl ...
- DesignPattern(二) 创建型模式
创建型模式 创建型模式就是用来创建对象的模式,抽象了实例化的过程.所有的创建型模式都有两个共同点.第一,它们都将系统使用哪些具体类的信息封装起来:第二,它们隐藏了这些类的实例是如何被创建和组织的.创建 ...
- [BZOJ5330][SDOI2018]反回文串
luogu bzoj sol 枚举一个长度为\(n\)为回文串,它的所有循环位移都可以产生贡献. 但是这样算重了.重复的地方在于可能多个回文串循环同构,或者可能有的回文串经过小于\(n\)次循环位移后 ...
- 【idea】如何安装jetty容器,并使用。
参考:https://www.jetbrains.com/idea/help/run-debug-configuration-jetty-server.html背景:web开发当中,我觉得服务层的代码 ...
- java的堆和栈
初始入门嗯:https://www.cnblogs.com/SaraMoring/p/5687466.html 堆空间:new出来的数组和对象,对象和数组没有引用指向它的时候,等待下一次垃圾回收 栈空 ...
- VB中上传下载文件到SQL数据库
VB中上传下载文件到SQL数据库 编写人:左丘文 2015-4-11 近期在修改一个VB编写的系统时,想给画面增加一个上传文件到数据库,并可以下载查看的功能,今天在这里,我想与大家一起分享代码,在此做 ...
- 使用 Lombok 简化项目中无谓的Java代码
在写使用Java时,难免会有一些模板代码要写,不然get/set,toString, hashCode, close 资源,定义构造函数等等.代码会显得很冗余,很长.Lombok项目可以是我们摆脱这些 ...
- Javamail使用代码整理
package com.hengrun.mail; import java.io.*; import java.security.Security; import java.text.SimpleDa ...
- Bootstrap-Other:Less 教程
ylbtech-Bootstrap-Other:Less 教程 1.返回顶部 1. 2. 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 1. http://www.runoob. ...
- 学习笔记之SQL 教程
SQL 教程 | 菜鸟教程 http://www.runoob.com/sql/sql-tutorial.html SQL,指结构化查询语言,全称是 Structured Query Language ...