python is和==的区别

# ==和is

# ==用来判断值是否相等
# is是用看来判断是不是指定了同一个东西,判断是不是指向了同一个地址等

a = [11,22,33]
b = [11,22,33]

a == b # True
a is b # False

print(id(a))              
print(id(b))


c = a
print(id(c))

print(a is c)


a = 100

b = 100

print(a == b)
print(a is b)
print("===============")
a = 100000000
b = 100000000
print(a == b)
print(a is b)

posted @ 2018-08-07 16:06  红尘陌上,独自行走  阅读(89)  评论(0编辑  收藏  举报