歌词遍历案例 lrc文件
代码
//A code block
import time
musicLrc="""
[00:00.64]背后女人 - 杨千嬅/周柏豪
[00:03.17]词:Tim Lui
[00:03.95]曲:周柏豪
[00:05.30]编曲:周锡汉/黄兆铭
[00:05.63]监制:周锡汉
[00:06.49]OP:Click Music Limited
[00:06.65]SP: Music Nation Publishing Company Limited (50%)
[00:07.42]OP:Shoot The Lyricist admin by Universal Music Publishing Limited (50%)
[00:09.51]
[00:15.40]男:
[00:16.18]身与心去为明日奔驰
[00:20.89]女:
[00:22.31]同样为家栽出暖意
[00:25.98]
[00:26.56]谁人在等一双臂靠倚
[00:30.48]男:
[00:31.41]可记起谁日和夜坚持
[00:35.97]
[00:36.68]女:
[00:37.91]长期用心打点细致
[00:41.40]原期望枕边一个
[00:43.95]合:
[00:44.47]快乐惬意
[00:47.38]男:
[00:49.88]这背影每天沿路照应
[00:54.19]女:
[00:55.28]不需得到掌声
[00:57.90]男:
[00:58.73]当天答应
[01:00.45]女:
[01:00.81]想兑现着
[01:02.39]男:
[01:02.85]一生的笑声
[01:03.76]女:
[01:03.99]一生所爱保证
[01:05.44]男:
[01:05.81]偏错失了 未陪伴细听
[01:09.27]合:
[01:10.19]那些内心的感性
[01:12.61]女:
[01:13.98]请不忘重拾步履
[01:16.42]合:
[01:17.19]行过最幸福小径
[01:20.37]
[01:34.32]男:
[01:34.98]心里的那小孩乱呼救
[01:39.30]女:
[01:41.67]同时在安抚小怪兽
[01:44.54]
[01:45.34]如何受压都不会放手
[01:49.26]男:
[01:50.12]懂那心理 脆弱时营救
[01:54.94]合:
[01:56.43]这些时间里 岁月看透
[02:01.02]在背后那份爱 珍惜可会未够
[02:06.34]
[02:07.90]男:
[02:08.87]这背影每天沿路照应
[02:12.81]女:
[02:14.09]不需得到掌声
[02:16.65]男:
[02:17.75]当天答应
[02:19.11]女:
[02:19.58]想兑现着
[02:21.11]男:
[02:21.60]一生的笑声
[02:22.55]女:
[02:22.85]一生快乐笑声
[02:24.08]男:
[02:24.49]偏错失了 未陪伴细听
[02:27.73]合:
[02:28.88]那些内心的感性
[02:31.77]女:
[02:32.71]请不忘重拾步履
[02:35.35]合:
[02:35.93]行过最幸福小径
[02:39.37]
[02:52.26]女:
[02:54.08]所有一切来自爱吧
[02:57.04]男:
[02:58.09]不歇息每天
[02:59.39]合:
[02:59.94]期待开花
[03:02.07]
[03:07.31]男:
[03:08.73]这背影每天沿路照应
[03:12.54]女:
[03:13.27]
[03:13.99]不需得到掌声
[03:16.40]男:
[03:17.51]当天答应
[03:19.18]女:
[03:19.54]想兑现着
[03:20.77]男:
[03:21.26]每日的笑声
[03:23.01]女:
[03:23.24]每日欢乐笑声
[03:24.24]男:
[03:24.43]不要等到 没能力细听
[03:27.96]合:
[03:28.84]让爱未得到呼应
[03:31.34]女:
[03:32.56]请坚持重拾步履
[03:35.65]合:
[03:36.20]行过最幸福小径
[03:39.11]
[03:42.15]男:
[03:46.38]可记起那天门外一吻
[03:50.26]女:
[03:52.85]点点的爱可刻骨铭心
[03:55.92]男:
[03:56.70]延续着这种相爱
[03:59.35]合:
[03:59.87]到白鬓"""
print("*"*50)
musicLrcList=musicLrc.splitlines() #按行处理
lrcDict={}
#runCount=lrcLine.count(’:’)
for lrcLine in musicLrcList:
lrcLineList=lrcLine.split(’]’)
for index in range(len(lrcLineList)-1):
timeStr=lrcLineList[index][1:]
timeList=timeStr.split(’:’)
time1=float(timeList[0])*60+float(timeList[1])
lrcDict[time1]=lrcLineList[-1]
print(lrcDict)
allTimeList=[]
for t in lrcDict:
allTimeList.append(t)
allTimeList.sort()
print(allTimeList)
“”“while 1:
getTime=float(input(“请输入一个时间”))
for n in range(len(allTimeList)):
tempTime=allTimeList[n]
if getTime<tempTime:
break
if n==0:
print(“时间太小”)
else:
print(lrcDict[allTimeList[n-1]])
“””
getTime=0
while 1:
for n in range(len(allTimeList)):
tempTime = allTimeList[n]
if getTime < tempTime:
break
lrc=lrcDict.get(allTimeList[n-1])
if lrc==None:
pass
else:
print(lrc)
time.sleep(1)
getTime+=2
"""
if n == 0:
#print("时间太小")
pass
else:
print(lrcDict[allTimeList[n - 1]])
"""