from pymongo import MongoClient mongoClient = MongoClient('localhost',27017) #準備一個client db= mongoClient['helloworld'] #選擇db collection = db['test'] #選擇collection total = collection.find().count() #total