Python教程之src转为html
程序员文章站
2022-04-08 23:17:07
...
实战需求
Python教程之src转为html
实战代码
fname = "1. What is Vapor"
fname_ext = "srt"
rname = fname+"_br.html"
rstr = ""
flines = open(fname+"."+fname_ext).readlines()
for item in flines:
rstr = rstr + item.replace("\n","<br><br>\n")
with open(rname,'w') as r:
r.write(rstr)
fname = "en.srt"
rname = "zh.srt"
rstr = ""
flines = open(fname).readlines()
for item in flines:
if item == "\n":
continue
else:
rstr = rstr + item
with open(rname,'w') as r:
r.write(rstr)