TypeError: 类型对象 'Cursor' 没有 len//

我收到此错误:

TypeError: 类型对象 'Cursor' 没有 len//

当我尝试完成:


reply = db['test'].find/{"date":{"$gt":date_query}} ,{"date":1,"route_id":1,"loc":1,"_id":0}/

length = len/reply/
已邀请:

奔跑吧少年

赞同来自:

http://api.mongodb.org/python/ ... .html
pymongo 有一种方法
count//

, 这将返回您正在寻找的内容:


reply = db['test'].find/
{"date":{"$gt":date_query}},
{"date":1,"route_id":1,"loc":1,"_id":0}
/

length = reply.count//

君笑尘

赞同来自:

是的,图表将为您制作所有工作。


length = reply.count//


或者


length = reply.count/with_limit_and_skip=False/


我不得不非常痛苦,因为 length = count /reply/ 也没有工作。 由于我不被允许发表评论,我决定留下这个答案。 我希望这将有助于别人节省一点时间。

卫东

赞同来自:

以。。。开始
Mongo 4.0.3

/
PyMongo 3.7.0

, 您可以使用
https://api.mongodb.com/python ... ments
反而
count


cursor

:


db.collection.count_documents/{ "a": 2 }/
# where { "a": 2 } is whatever filtering query



db.collection.count_documents

- 这是过时的替代品
https://api.mongodb.com/python ... count
.

要回复问题请先登录注册