我已经安装了textblob,我想执行简单的翻译。
>>> text="Hello"
>>> blob=TextBlob(text)
>>> blob.translate(to="es")问题是,我不知道在哪里指定代理身份验证。你能告诉我在哪里指定用户名,密码和代理地址,以便我可以让它工作吗?
发布于 2016-06-03 17:35:18
我在我的代码中应用了这个技巧,它工作得很好。
1)导入nltk库。
2)在您的代码中插入这一行,根据需要替换用户名、密码、代理和端口:
nltk.set_proxy('http://username:password@proxy:port')现在,您的代码将如下所示:
import textblob
import nltk
from textblob import TextBlob
text="Hello"
blob=TextBlob(text)
nltk.set_proxy('http://username:password@proxy:port')
blob.translate(to="es")
print(blob.translate(to="es"))https://stackoverflow.com/questions/34036158
复制相似问题