码迷,mamicode.com
首页 > 编程语言 > 详细

Python基础03 id

时间:2017-09-22 11:51:55      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:相等   引用   bsp   函数   span   not   and   地址   操作   

id

id(x)对应变量x所引用对象的内存地址。可以把id(x)看成变量x的身份标识。

is

有时在编程中需要与变量的身份标识打交道,但不是通过 id 函数,而是 is 操作符。

The operators is and is not test for object identity: x is y is true if and only if x and are the same object.

可以简单把a is b 看成 id(a) == id(b)。

==

== 操作符也可用于相等性比较,只是比较的是内容的相等性,而不是身份标识的相等性。

 

Python基础03 id

标签:相等   引用   bsp   函数   span   not   and   地址   操作   

原文地址:http://www.cnblogs.com/gattaca/p/7573661.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!