歌詞解析器2

代碼展示

with open('lrc/李宗盛-凡人歌.lrc','r',encoding='gbk') as f:
    list_tmp=list(f.readlines())
list_tmp=[[y[1:] for y in x.split(r']')[:-1]]+[x.split(r']')[-1].strip()] for x in list_tmp]
list_tmp=sorted(list_tmp,key=lambda x:x[0])
for x in range(len(list_tmp)-1):
    end=list_tmp[x+1][0].split(':')
    start=list_tmp[x][0].split(':')
    print(end,start)
    end=int(end[0])*60+float('%.2f'%float(end[1]))
    start=int(start[0])*60+float('%.2f'%float(start[1]))
    list_tmp[x].insert(1,end-start)

print(list_tmp)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章