美文网首页
"is" vs. "=="

"is" vs. "=="

作者: import_hello | 来源:发表于2018-10-16 07:11 被阅读0次
# "is" vs "=="

>>> a = [1, 2, 3]
>>> b = a

>>> a is b
True
>>> a == b
True

>>> c = list(a)

>>> a == c
True
>>> a is c
False

# • "is" expressions evaluate to True if two 
#   variables point to the same object

# • "==" evaluates to True if the objects 
#   referred to by the variables are equal

相关文章

网友评论

      本文标题:"is" vs. "=="

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