请看下面的代码:
collection = db_name.get_db().collection_name
print collection
# prints .. Collection(Database(Connection('localhost', 27017), u'db_name'), u'colelction_name')
for key in some_dict.keys():
query = {"p_id":key}
document = collection.find(query)
print document
# gives <pymongo.cursor.Cursor object at 0x7f13f3049b10>
现在我想检索这个文档.. 并获取数据。但如果我这样做:
for d in document:
print d
我收到以下错误
File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 703, in next
if len(self.__data) or self._refresh():
File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 666, in _refresh
self.__uuid_subtype))
File "/usr/local/lib/python2.7/dist-packages/pymongo/cursor.py", line 628, in __send_message
self.__tz_aware)
File "/usr/local/lib/python2.7/dist-packages/pymongo/helpers.py", line 101, in _unpack_response
error_object["$err"])
我究竟做错了什么?谢谢