利用 谷歌 python 快速翻译 英文字幕
2021-01-19 00:12
标签:readline a long dir isod 谷歌 字符 span lock over 准备好srt字幕文件 格式例如: 1 2 3 把上述文件 通过 谷歌翻译翻译成 如下: 1个 2 3 并且保存成带有 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 我生命中的多年尝试 利用 谷歌 python 快速翻译 英文字幕 标签:readline a long dir isod 谷歌 字符 span lock over 原文地址:https://www.cnblogs.com/xfbx/p/12910957.html前期准备
00:00:04,990 --> 00:00:07,759
for a long time now I‘ve been wanting to
00:00:07,759 --> 00:00:11,690
shoot an episode where I distill over 20
00:00:11,690 --> 00:00:13,549
years of my life experience trying to
00:00:04,990-> 00:00:07,759
很长一段时间以来,我一直想
00:00:07,759-> 00:00:11,690
拍摄一集我蒸馏超过20集的情节
00:00:11,690-> 00:00:13,549
我生命中的多年尝试编写python代码
剩下的就是手动修改了.
文章标题:利用 谷歌 python 快速翻译 英文字幕
文章链接:http://soscw.com/index.php/essay/43851.html