python

python中查看变量内存地址的方法

2017-07-19  本文已影响608人  andyJi
id(object) -> integer
Return the identity of an object.  This is guaranteed to be unique among
simultaneously existing objects.  (Hint: it's the object's memory address.)

使用:id(obj)


id(obj)得到obj的内存地址(10进制)

>>> sq = [0, 1, 2]
>>> print id(sq)
4345610824
上一篇下一篇

猜你喜欢

热点阅读