我已经安装了textblob,我想进行简单的翻译。
>>> text="Hello"
>>> blob=TextBlob(text)
>>> blob.translate(to="es")
问题是,我不知道在哪里指定代理身份验证。你能告诉我在哪里指定用户名、密码和代理地址,以便我可以让它工作吗?
请您参考如下方法:
我在我的代码中应用了这个技巧,它运行良好。
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"))
