更新多个/所有文档
- import pymongo
- myclient = pymongo.MongoClient("mongodb://localhost:27017/")
- mydb = myclient["mydatabase"]
- mycol = mydb["customers"]
- myquery = { "address": { "$regex": "^S" } }
- newvalues = { "$set": { "name": "Minnie" } }
- x = mycol.update_many(myquery, newvalues)
- print(x.modified_count, "documents updated.")