python tips
时间:2011-01-11 来源:phoebus0501
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]
相关阅读 更多 +