用google translate大文件
2024-08-26 10:41:08
问题:
google translate对于大文件不支持,咋办?
思路:自己写个函数把的文件拆成小文件,再用google translate!
code:
from googletrans import Translator
import sys
translator = Translator()
fname=sys.argv[]
foname=fname + '-cn.txt'
cont=open(fname).read()
fdes = open(foname,'w')
N=
i=
L=len(cont)
while i<L:
print (1.0*i/L)
i2 = min(i+N, L)
subCont = cont[i:i2]
s=(translator.translate(subCont, src='en', dest='zh-cn'))
try:
fdes.write(str(s.text))
except:
pass
i = i+N
fdes.close()
最新文章
- Windows下搭建PHP开发环境
- Centos:Another app is currently holding the yum lock; waiting for it to exit...
- 损失函数(Loss Function)
- .net社区
- Instuments工具
- ANT自动打包U3D安卓项目研究笔记
- RPI学习--wiringpi_API
- angularjs + springmvc 上传和下载
- Dropping tests(01分数规划)
- ZSTU OJ 3999 零基础学算法---邻接表
- [AHOI2012]树屋阶梯
- bzoj 1426 收集邮票
- 在写php项目时 修改外部css或js文件没有效果
- 洛谷P5110 块速递推 [分块]
- 小程序里let和var以及const区别
- JAVA 同步之 synchronized 修饰方法
- C++经典面试题(最全,面中率最高)
- lua_tinker源码笔记1
- HIHOcoder 1441 后缀自动机一&#183;基本概念
- ActionCable的部署(参考Gorails)