user@ubuntu:~$python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> # Method one
>>> from bson.objectid import ObjectId
>>> idA = ObjectId()
>>> print(idA)
4e9c45b91d41c8079a000000
>>> # Method two
>>> import bson
>>> idB = bson.ObjectId()
>>> print(idB)
4e9c45ca1d41c8079a000001
谢谢
解决方法:
In [5]: bson.ObjectId
Out[5]: bson.objectid.ObjectId
他们是完全一样的东西.