高级查询

  1. import pymongo
  2.  
  3. myclient = pymongo.MongoClient("mongodb://localhost:27017/")
  4. mydb = myclient["mydatabase"]
  5. mycol = mydb["customers"]
  6.  
  7. #address greater than S:
  8. myquery = { "address": {"$gt": "S"} }
  9.  
  10. mydoc = mycol.find(myquery)
  11.  
  12. for x in mydoc:
  13. print(x)