What is the id( ) function used for?

前端 未结 13 994
傲寒
傲寒 2020-11-22 10:51

I read the Python 2 docs and noticed the id() function:

Return the “identity” of an object. This is an integer (or long integer) which is

相关标签:
13条回答
  • 2020-11-22 11:15

    Be carefull (concerning the answer just below)...That's only true because 123 is between -5 and 256...

    In [111]: q = 257                                                         
    
    In [112]: id(q)                                                            
    Out[112]: 140020248465168
    
    In [113]: w = 257                                                         
    
    In [114]: id(w)                                                           
    Out[114]: 140020274622544
    
    In [115]: id(257)                                                         
    Out[115]: 140020274622768
    
    0 讨论(0)
提交回复
热议问题