sponsored links

pymongo中如何生成ObjectId

引用from bson import ObjectId就可以啦。

如:

#encoding:utf-8
import pymongo
from bson import ObjectId

dbconnection=pymongo.Connection('localhost',27017)
db = dbconnection.test
coll = db.user

d=coll.find_one({'_id':ObjectId('577d211b1d41c8303f73cf7d')})

(转自 https://wuwawuwa.cn)

Tags: