- 库名:pygtrans–python google translate
- 检测待翻译字符串的类型,中文翻译成英文,英文翻译成中文
from pygtrans import Translate
client = Translate()
Question = '你好'
laguage = client.detect(Question).language ## 检测语言
if laguage == 'zh-CN':
## 将中文翻译成英文
Question = client.translate(Question, target='en')
Question = Question.translatedText ## str类型
## 将英文翻译成中文
text = client.translate(Question)
anwser = text.translatedText ## str类型
该文章介绍了如何利用Python库pygtrans进行文本语言检测和翻译,包括从中文到英文以及从英文回译到中文的过程。


被折叠的 条评论
为什么被折叠?



