删除文档

  1. import pymongo
  2.  
  3. myclient = pymongo.MongoClient("mongodb://localhost:27017/")
  4. mydb = myclient["mydatabase"]
  5. mycol = mydb["customers"]
  6.  
  7. myquery = { "address": "Mountain 21" }
  8.  
  9. mycol.delete_one(myquery)
  10.  
  11.  
  12. #print the customers collection after the deletion:
  13. for x in mycol.find():
  14. print(x)