python教程之如何将srt转为文本
程序员文章站
2022-04-08 23:16:49
...
实战需求
python教程之如何将srt转为文本
实战代码
def split2step(alist,step):
rs = []
for i in range(0,len(alist),step):
rs.append(alist[i:i+step])
return rs
fname = "1. What is Vapor.srt"
rname = "1. What is Vapor_en.html"
flines = open(fname).readlines()
f4 = split2step(flines,4)
rs = ""
for item in f4:
rs = rs+item[2].replace("\n","")
with open(rname,'w') as r:
r.write(rs)
推荐阅读