限制结果

  1. import pymongo
  2.  
  3. myclient = pymongo.MongoClient("mongodb://localhost:27017/")
  4. mydb = myclient["mydatabase"]
  5. mycol = mydb["customers"]
  6.  
  7. myresult = mycol.find().limit(5)
  8.  
  9. #print the result:
  10. for x in myresult:
  11. print(x)