python判断mongodb--find(),find_one()返回是否为空
(2018-03-10 17:50:43)
标签:
pythonmongofindfind_one |
分类: Python |
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'