import pymongo client = pymongo.MongoClient('localhost',9888) walden = client['walen'] //数据库 sheet_tab = walden['sheet_tab'] //collections
for item in sheet_tab.find(): //查询数据 print(item['name'])
$lt/$lte/$gt/$gte/$ne, 依次等价于</<+/>/>=/!= (l表示less g表示greater e表示equal n表示not)
for item in sheet_tab.find({'index':{'$lt':500}}): //index小于500 print(item)
更新操作:udb.collection.update()
例:{id:1,name:0,info:3}
update({id:1},{$set:{name:2}}) 把id为1的项的name更改为2
update({'_id':i['_id']},{'$set':{'area':area}}) 更新所有项的area