我得到了这个错误:
TypeError:类型为"Cursor"的对象没有len()
当我try 执行时:
reply = db['test'].find({"date":{"$gt":date_query}} ,{"date":1,"route_id":1,"loc":1,"_id":0})
length = len(reply)
我得到了这个错误:
TypeError:类型为"Cursor"的对象没有len()
当我try 执行时:
reply = db['test'].find({"date":{"$gt":date_query}} ,{"date":1,"route_id":1,"loc":1,"_id":0})
length = len(reply)
pymongo cursor有一个方法count()
,它会返回你想要的东西:
reply = db['test'].find(
{"date":{"$gt":date_query}},
{"date":1,"route_id":1,"loc":1,"_id":0}
)
length = reply.count()