问题:

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()

最新文章

  1. Windows下搭建PHP开发环境
  2. Centos:Another app is currently holding the yum lock; waiting for it to exit...
  3. 损失函数(Loss Function)
  4. .net社区
  5. Instuments工具
  6. ANT自动打包U3D安卓项目研究笔记
  7. RPI学习--wiringpi_API
  8. angularjs + springmvc 上传和下载
  9. Dropping tests(01分数规划)
  10. ZSTU OJ 3999 零基础学算法---邻接表
  11. [AHOI2012]树屋阶梯
  12. bzoj 1426 收集邮票
  13. 在写php项目时 修改外部css或js文件没有效果
  14. 洛谷P5110 块速递推 [分块]
  15. 小程序里let和var以及const区别
  16. JAVA 同步之 synchronized 修饰方法
  17. C++经典面试题(最全,面中率最高)
  18. lua_tinker源码笔记1
  19. HIHOcoder 1441 后缀自动机一&#183;基本概念
  20. ActionCable的部署(参考Gorails)

热门文章

  1. python 全局声明 global
  2. js的异常处理 try catch
  3. 【测试工具】moco入门(一)
  4. c语言逆序
  5. MySQL InnoDB存储引擎事务的ACID特性
  6. 如何更好的使用js?
  7. Oracle row_number() over() 分析函数--取出最新数据
  8. 【概率论】5-8:Beta分布(The Beta Distributions)
  9. pycharm通过pytest运行报错:No test were found 解决
  10. dhcp自动分配地址