python判断mongodb--find(),find_one()返回是否为空

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'

---------------------------------------------------------------------------------


关注微信公众号即可在手机上查阅,并可接收更多测试分享~



原文地址:https://www.cnblogs.com/songzhenhua/p/9312711.html