In Python, the difference between the operator "==" and "is"
"==" is used to determine whether the values of the objects pointed to by two variables are the same.
"Is" is used to determine whether two variables point to the same object.
E.g:
a = 123
b = a
c = 1234
#a、b指向对象123,指向同一个对象
print(a == b)
print(a is b)
#a指向对象123,c指向对象1234,变量a、c指向不同对象
print(a == c)
print(a is c)
Output result:
True
True
False
False
Note : The operator "is not" can also be used to determine whether two variables point to the same object, but the effect is the opposite of "is". If they point to the same object, it outputs false, otherwise it outputs true.