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

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

猜你喜欢

转载自blog.csdn.net/jichunw/article/details/80284509