==、is
In [1]: a = [11,22,33]
In [2]: b = a
In [3]: a == b
Out[3]: True
In [4]: a is b
Out[4]: True
In [6]: import copy
In [7]: c = copy.deepcopy(a)
In [8]: a == c
Out[8]: True
In [9]: a is c
Out[9]: False
总结
- is 是比较两个引用是否指向了同一个对象(引用比较)。
- == 是比较两个对象是否相等。