美文网首页python
python中查看变量内存地址的方法

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

作者: andyJi | 来源:发表于2017-07-19 13:12 被阅读608次
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

相关文章

网友评论

    本文标题:python中查看变量内存地址的方法

    本文链接:https://www.haomeiwen.com/subject/stdlkxtx.html