我已经安装了textblob,我想进行简单的翻译。
>>> text="Hello"
>>> blob=TextBlob(text)
>>> blob.translate(to="es")
问题是,我不知道在哪里指定代理身份验证。你能告诉我在哪里指定用户名,密码和代理地址,以便我可以使用它吗?
答案 0 :(得分:1)
我在我的代码中应用了这个技巧,它运行正常。
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"))