标签:readline a long dir isod 谷歌 字符 span lock over
准备好srt字幕文件 格式例如:
1
00:00:04,990 --> 00:00:07,759
for a long time now I‘ve been wanting to2
00:00:07,759 --> 00:00:11,690
shoot an episode where I distill over 203
00:00:11,690 --> 00:00:13,549
years of my life experience trying to
把上述文件 通过 谷歌翻译翻译成 如下:
1个
00:00:04,990-> 00:00:07,759
很长一段时间以来,我一直想2
00:00:07,759-> 00:00:11,690
拍摄一集我蒸馏超过20集的情节3
00:00:11,690-> 00:00:13,549
我生命中的多年尝试
并且保存成带有 trans 字符的文件
import os
for root,dirs,files in os.walk("./"):
for name in files:
if "srt" in name:
fr=open("./"+name,"r",encoding="utf-8")
frlist = fr.readlines()
fr.close()
if "trans" in name:
ft = open("./" + name, "r",encoding="utf-8")
ftlist = ft.readlines()
ft.close()
with open("./结果.txt","w",encoding="utf-8")as fe:
for i in range(0,(len(frlist))):
fe.write(frlist[i])
if (i%4==2):
fe.write(ftlist[i])
翻译的中文字幕包涵 trans 字符
原始英文包涵 srt 字符
与python文件在同一文件夹下.
生成结果如下:
1
00:00:04,990 --> 00:00:07,759
for a long time now I‘ve been wanting to
很长一段时间以来,我一直想
2
00:00:07,759 --> 00:00:11,690
shoot an episode where I distill over 20
拍摄一集我蒸馏超过20集的情节
3
00:00:11,690 --> 00:00:13,549
years of my life experience trying to
我生命中的多年尝试
标签:readline a long dir isod 谷歌 字符 span lock over
原文地址:https://www.cnblogs.com/xfbx/p/12910957.html