我正试图在googleappengine应用程序中使用pyDictionary,但出现了一个错误。当我在google应用程序之外使用它时,我不会得到这个错误。我已经添加了它作为第三方库(正确的),所以它实际上导入它没有错误,所以我不知道为什么。你知道吗
错误如下:
searching.py", line 63, in getkey assert isinstance(word.keys, object)
AttributeError: 'NoneType' object has no attribute 'keys'
下面是该函数的代码:
def getkey(term):
dictionary = PyDictionary()
word = dictionary.meaning(term)
assert isinstance(word.keys, object)
results = word.keys()
newresults = []
for result in results:
newresults.append(str(result))
return newresults[0]
它在appengine项目外部工作,但在内部不工作。。。你知道吗
你应该回头看看你的异常,试着理解它告诉你什么。你知道吗
让我们追溯到你的代码。你知道吗
因为发生错误意味着
word
引用的值是None。你知道吗这意味着
word = dictionary.meaning(term)
的结果是
None
。你知道吗所以你应该看看
term
的值是多少。你知道吗你在验证
term
在任何地方都是有意义的吗?如果是,那么dictionary.meaning(term)
的预期结果是什么,然后调查为什么没有得到预期结果。你知道吗一些基本的调试可以帮助您诊断问题。你知道吗
相关问题 更多 >
编程相关推荐