python

时间:2016-03-17 09:36:44

标签: python variable-assignment

a = b = ['a', 'b'] 
b = ['x', 'y'] # reassigns the name b
print a # still the original list

a = b = ['a', 'b']
b[:] = ['x', 'y'] # changes the existing list bound to a 
print a # a changed too 

为什么a与b有关? python使用什么样的机制来处理可变数据类型的链式赋值?

0 个答案:

没有答案
相关问题