res = collection.find({})
怎么知道返回的res的条数?
res = collection.find({})
怎么知道返回的res的条数?
import pymongo
client = pymongo.MongoClient(host='localhost', port=27017)
counT = client["databaseName"]["collectionName"].count_documents(filter={})
print(f"num of documents in this collection is {counT}")
输出结果:
num of documents in this collection is 305