我编写了一个名为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]
发布于 2016-05-03 17:01:21
PyDictionary使用Google翻译进行翻译,并且正如它用来访问Google翻译的模块的PyPI页面上所指出的那样,谷歌改变了一些东西来阻止这种情况。PyDictionary翻译将不再起作用。
https://stackoverflow.com/questions/37009972
复制相似问题