Use Python to help me write a translation code

You're welcome, I'm happy to help! Here is a simple translation code: def translate(text): '''Translates the given text from English to Chinese.'''

# Use the Google Translate API
translator = Translator()
result = translator.translate(text, dest='zh-cn')
return result.text

Guess you like

Origin blog.csdn.net/weixin_42592399/article/details/129526414