DeprecationWarning: count is deprecated. Use Collection.count_documents instead.

2018-07-31 16:44:17 +08:00
 Kakarrot

如何避免这个报错呢?

def get_registered_user():
    users = collection_users.find({'regDate': regDate}).count()
    pprint.pprint("注册用户:" + str(users))
5430 次点击
所在节点    Python
4 条回复
thebigban
2018-07-31 16:54:20 +08:00
提示你使用 count_document,count 应该是老的方法了,换一个方法就好了
Kakarrot
2018-07-31 16:56:59 +08:00
@thebigban
users = collection_users.find({'regDate': regDate}).count()
改成
users = collection_users.find({'regDate': regDate}).count_documents
users = collection_users.find({'regDate': regDate}).count_documents()
都不行啊
Kakarrot
2018-07-31 17:24:27 +08:00
```
def get_registered_user():
users = collection_users.count_documents({'regDate': regDate})
pprint.pprint("注册用户:" + str(users))
```
datou
2018-07-31 17:38:00 +08:00
mongo 这些提示我从来不管的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/475706

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX