from bson.objectid import ObjectId 1、字符串转ObjectId oid = ObjectId(id_str); 2、ObjectId转字符串 id_str = ObjectId(id).toString() 例子 find({'_id': ObjectId(id_str)})