Return the "identity'' of an object.
This is an integer (or long integer)
which is guaranteed to be unique and
constant for this object during its
lifetime. Two objects with
non-overlapping lifetimes may have the
same id() value. (Implementation note:
this is the address of the object.)
您可以这样重新实现默认repr:
只是使用
关于
id()
,Python manual可以这样说:所以在CPython中,这将是对象的地址。不过,对于其他任何Python解释器都没有这样的保证。
注意,如果您正在编写一个C扩展,那么您可以完全访问Python解释器的内部,包括直接访问对象的地址。
相关问题 更多 >
编程相关推荐