python判断两个变量是否指向同一个对象

a = 5
b = 6
c = 6
print(a is b)    # False
print(a is c)    # False
print(b is c)    # True
print(id(a), id(b), id(c))   # 504911664 504911680 504911680

你可能感兴趣的:(Python)