from pymongo import MongoClient
client = MongoClient("mongodb://localhost:27017/")
database = client["learn"]
collection = database["people"]
# Created with Studio 3T, the IDE for MongoDB - https://studio3t.com/
query ={}
query['age']=33
cursor = collection.find(query)
# 捕获异常try:
for doc in cursor:
print(doc["name"])
#释放资源finally:
cursor.close()