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'

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


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



posted @ 2018-03-10 17:51  ☆星空物语☆  阅读(2022)  评论(0编辑  收藏  举报