from pymongo import MongoClient mongoClient = MongoClient('localhost',27017) #准备一个client db= mongoClient['helloworld'] #选择db collection = db['test'] #选择collection total = collection.find().count() #total