from googletrans import Translator
def trans(text):
translator = Translator()
return translator.translate(text, dest='en').text
if __name__ == '__main__':
res = trans("我是最帅的")
print(res)
from googletrans import Translator
def trans(text):
translator = Translator()
return translator.translate(text, dest='zh-CN').text
if __name__ == '__main__':
res = trans("Thank for reading")
print(res)
一次翻译的长度是有限的,建议每一句一翻译
来源:CSDN
作者:追梦小狂魔
链接:https://blog.csdn.net/qq_15557299/article/details/104184731