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参数类型 形参:定义函数时的参数变量. 实参:调用函数时使用的参数变量. 参数传递的过程 ...
随机推荐
- CH3301 同余方程
题意 3301 同余方程 0x30「数学知识」例题 描述 求关于 x的同余方程 ax ≡ 1(mod b) 的最小正整数解. 输入格式 输入只有一行,包含两个正整数a,b,用一个空格隔开. 输出格式 ...
- macOS --- 配置基于域名的虚拟主机
在终端运行 sudo vi /Applications/XAMPP/xamppfiles/etc/httpd.conf,打开apache配置文件. 在httpd.conf中找到"#Inclu ...
- tomcat自启动脚本
1.#cd /etc/rc.d/init.d2.#vi tomcat3.把下面的代码保存为tomcat文件,并让它成为可执行文件 chmod 755 tomcat. #!/bin/sh # # /et ...
- RabbitMQ 概念与Java例子
RabbitMQ简介 目前RabbitMQ是AMQP 0-9-1(高级消息队列协议)的一个实现,使用Erlang语言编写,利用了Erlang的分布式特性. 概念介绍: Broker:简单来说就是消息队 ...
- 3——FFMPEG之解复用器-----AVInputFormat(转)
1. 数据结构: AVInputFormat为FFMPEG的解复用器对象,通过调用av_register_all(),FFMPEG所有的解复用器保存在以first_iformat为链表头的链表中,且还 ...
- 网站配色、网站模板网址 UE样式 metro报表
http://www.colourlovers.com http://unmatchedstyle.com网站模板目录 花瓣 http://huaban.com/ 油表 http://fl ...
- thinkphp3.2.3+smarty解决success调用模板错误心得
最近学习thinkphp上瘾,出现success找不到模板问题,查阅各大神解决方案,分享一下针对新手如何解决该问题,如有不对的地方请大神指正 1.首先修改自己的config文件,添加如下配置代码:// ...
- 异步编程 In .NET(转载)
概述 在之前写的一篇关于async和await的前世今生的文章之后,大家似乎在async和await提高网站处理能力方面还有一些疑问,博客园本身也做了不少的尝试.今天我们再来回答一下这个问题,同时我们 ...
- Non-standard evaluation, how tidy eval builds on base R
As with many aspects of the tidyverse, its non-standard evaluation (NSE) implementation is not somet ...
- log4net 使用指南,最常遇到的问题整理。。。
一. Log4net特征 Log4net是一个用于.NET开发环境的日志记录组件,由于它的超快及超灵活,很多大型的应用都会用到. 它有如下特点: 1.自定义日志输出级别 ...