==比较内容相等性

is测试对象相等性

X=[1,2,3];
Y
=X[:];
print('X',X);
print('Y',Y);
print(X==Y);
print(X is Y);


X[
2]=2;
print('X',X);
print('Y',Y);

结果

 

X [1, 2, 3]
Y [1, 2, 3]
True
False
X [1, 2, 2]
Y [1, 2, 3]