[英]How to retrieve translation from TextBlob translate
I'm using TextBlob to translate a sentence, and for the life of me I can't figure out how to retrieve the translated text as a string. 我正在使用TextBlob翻译一个句子,而对于我的生活,我无法弄清楚如何将翻译后的文本检索为字符串。 For example
例如
from textblob import TextBlob
trans = TextBlob('Hello World')
foo = trans.translate(to='la')
How can I assign the translated text as a variable? 如何将翻译后的文本指定为变量? Looking through the docs doesn't help.
浏览文档并没有帮助。
Ah, I got it, foobar = str(foo). 啊,我明白了,foobar = str(foo)。 That's all that is needed.
这就是所需要的。 foobar is now just a regular old string.
foobar现在只是一个普通的老字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.