删除多个文档

  1. import pymongo
  2.  
  3. myclient = pymongo.MongoClient("mongodb://localhost:27017/")
  4. mydb = myclient["mydatabase"]
  5. mycol = mydb["customers"]
  6.  
  7. myquery = { "address": {"$regex": "^S"} }
  8.  
  9. x = mycol.delete_many(myquery)
  10.  
  11. print(x.deleted_count, "documents deleted")