我制作了以下脚本,名为translate.py:
from PyDictionary import PyDictionary
dictionary=PyDictionary()
print (dictionary.meaning("indentation"))
print (dictionary.synonym("Life"))
print (dictionary.antonym("Life"))
print (dictionary.translate("Hello",'es'))
除了
之外,我收到了正确的输出 print (dictionary.translate("Hello",'es')):
这是我的命令行输出:
macintosh-3:reorder chibb9$ python translate.py
{u'Noun': ['a concave cut into a surface or edge (as in a coastline', 'the formation of small pits in a surface as a consequence of corrosion', 'the space left between the margin and the start of an indented line', 'the act of cutting into an edge with toothlike notches or angular incisions']}
[u'heart', u'growth', u'soul', u'activity', u'get-up-and-go']
[u'abstract', u'idleness', u'inactivity', u'laziness', u'lethargy']
Invalid Word
None
我已尝试使用不同语言代码的命令dictionary.translate( "[word]", "[language_code]")
许多不同的单词,并且我不断为每一对获得此输出:
Invalid Word
None
我也尝试使用PyDictionary github(http://github.com/geekpradd/PyDictionary)上列出的用法Web服务
但是我被定向到一个页面(图片附件,图片链接名称中的网页链接):
内部服务器错误
服务器遇到内部错误,无法完成您的请求。服务器过载或应用程序出错。
http://pydictionary-geekpradd.rhcloud.com/api/translate/[code]/[word]
答案 0 :(得分:0)
PyDictionary使用谷歌翻译进行翻译,并且如其用于访问谷歌翻译的模块的PyPI page所述,谷歌改变了一些东西以阻止这种情况发生。 PyDictionary翻译将不再适用。