python中查看變量內存地址的方法

本文實例講述了python中查看變量內存地址的方法。分享給大家供大家參考。具體實現方法如下:

這裏可以使用id

>>> print id.__doc__
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.)
>>>

>>> A=2
>>> B=3
>>> id (A)
505910880
>>> id(B)
505910896
>>> a=A
>>> id(a)
505910880
>>> a==A
True
>>> A=4
>>> id (A)
505910912
>>> a==A
False

希望本文所述對大家的Python程序設計有所幫助.




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章