low*_*tty 23 python translation
我正在尝试将大量文本文件从英语翻译成其他几种语言.我们在项目中使用Python,我们首先尝试使用Google翻译服务进行翻译,然后我们将手动纠正错误.
我想出了两种翻译方式:
使用Python Google翻译API.这里:goslate 1.1.2:Python包
尝试使用谷歌翻译页面进行编程,即输入我们要翻译的文本,模拟HTTP请求并处理响应.谷歌翻译
有没有人有更好的报价?
小智 8
尝试使用该googletrans模块。例如:
from googletrans import Translator
translator = Translator() # initalize the Translator object
translations = translator.translate(['see if this helps', 'tarun'], dest='hi') # translate two phrases to Hindi
for translation in translations: # print every translation
print(translation.text)
# Output:
# ????? ?? ?? ??? ???? ??
# ????
Run Code Online (Sandbox Code Playgroud)
支持的语言 (106) 及其 ISO639-1 代码的字典:
import googletrans
print(googletrans.LANGCODES) # {language name: iso639-1 language code}
# or
print(googletrans.LANGUAGES) # {iso639-1 language code: language name}
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅文档。
| 归档时间: |
|
| 查看次数: |
37665 次 |
| 最近记录: |