Use PyMongo to convert strings to objectid, according to official documents, but with errors
http://api.mongodb.org/python/1.7/api …
from pymongo.objectid import ObjectId key='507f1f77bcf86cd799439011' ObjectId(key)
错误消息 ImportError: No module named objectid
import bson.objectid # 或者 from bson import objectid>>> from bson.objectid import ObjectId >>> ObjectId('507f1f77bcf86cd799439011') ObjectId('507f1f77bcf86cd799439011')