Edw*_*ang 1 python cursor mongodb pymongo
我试图在 count() = 1 时做一些事情。我通过打印出来确认了 cursor.count() == 1,但是当我使用 cursor[0] 时,它引发了一个异常。
if not cursor.count():
return self.create_new_incident(tweet)
elif loc_cur.count() == 1:
return self.update_existing_incident(tweet, cursor[0])
....
File "/Library/Python/2.7/site-packages/pymongo/cursor.py", line 588, in __getitem__
raise IndexError("no such item for Cursor instance")
Run Code Online (Sandbox Code Playgroud)
IndexError: Cursor 实例没有这样的项目
我读到: 使用 pymongo 的 ReplicaSetConnection:有时会收到“IndexError:光标没有这样的项目” 我已经关闭了其他未使用的连接,但仍然无法正常工作。
提前致谢
归档时间: |
|
查看次数: |
7483 次 |
最近记录: |