您的位置:首页 > 移动开发 > Objective-C

Python 内建函数 - id(object)

2017-03-16 09:50 375 查看
Manual

直译

实例

Manual

Return the “identity” of an object. This is an 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.

CPython implementation detail: This is the address of the object in memory.

直译

返回object的“身份”,返回值为整数,是为了确保在对象的生命周期内的独特性和一致性,两个非重叠生命周期的对象可能有相同的id()值。

CPython实现细节:该值为对象的内存地址。

实例

>>> import os
>>> id(os)
44484096

>>> def foo(x):
print('Hello world! Hello ', x)
>>> id(foo)
58350808
>>> id(foo('Logan'))
Hello world! Hello  Logan
1568099016
# 注意id的变化
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python