conn = MongoClient('127.0.0.1', 27017)
db = conn.diff
collection = db['test1']
result = collection.find({"b":"a"})
if result.count() == 0:
print 'no data'
result = collection.find_one()
if result is None:
print 'no data'
---------------------------------------------------------------------------------
关注微信公众号即可在手机上查阅,并可接收更多测试分享~