我又回来了另一个python查询.我一直试图用列表中的项目进行一些计算.这是代码:
import math
def Usage() :
print "Usage :python beznew.py transcriptionsFile"
if __name__ == "__main__" :
if len(sys.argv) != 2 :
Usage()
else :
transcriptionFile = sys.argv[1]
tFile = open(transcriptionFile, "r")
for line in iter(tFile) :
list = line.split()
# changing the unit of time from 100 nano seconds to seconds
list[0] = list[0] / 100000000
list[1] = list[1] / 100000000
# duration of each phoneme
list = list[1] - list[0]
# extracting the start time of each phoneme
newlist = list.pop[0]
print list
print newlist
close.tFile
Run Code Online (Sandbox Code Playgroud)
输入文件如下所示:
000000 1200000 pau
1200000 1600000 dh
1600000 2000000 ih
2000000 3100000 k
3100000 3400000 aa
3400000 3800000 r
Run Code Online (Sandbox Code Playgroud)
我试图将数值更改为秒.并且还试图获得第一个和第二个数字之间的差异.它不允许我划分.我不明白我做错了什么.谢谢.