使用py2neo查詢neo4j時出現錯誤,而且似乎無法解決它。我的代碼:py2neo - 查詢中的UnicodeEncodeError
data, metadata = cypher.execute(self._db, 'START s=node:pages(title="%s") MATCH (s)-[r]->(n) RETURN n.title' % topic)
和錯誤
File "/usr/local/lib/python2.7/dist-packages/py2neo/cypher.py", line 50, in execute
results = query.execute(**params or {})
File "/usr/local/lib/python2.7/dist-packages/py2neo/neo4j.py", line 1011, in execute
return CypherResults(self._execute(**params))
File "/usr/local/lib/python2.7/dist-packages/py2neo/neo4j.py", line 1053, in __init__
self._data = [record(*_hydrated(row)) for row in content["data"]]
File "/usr/local/lib/python2.7/dist-packages/py2neo/neo4j.py", line 178, in _hydrated
return type(data)([_hydrated(datum) for datum in data])
File "/usr/local/lib/python2.7/dist-packages/py2neo/neo4j.py", line 177, in _hydrated
elif is_collection(data):
File "/usr/local/lib/python2.7/dist-packages/py2neo/util.py", line 134, in is_collection
hasattr(None, obj)
None: 'ascii' codec can't encode character u'\xeb' in position 5: ordinal not in range(128)
任何線索?
謝謝
我正在使用UTF-8。另外,我注意到這個問題發生在1.6版本的py2neo上,但不是1.5.1。 – user1491915
我會建議添加一個額外的除UnicodeEncodeError(返回False)到util.py中的is_collection方法。 – user1491915
GitHub提出了此問題:https://github.com/nigelsmall/py2neo/issues/187 –