源码:
a=[];pool=[]
for times in range(1,5):
a.append(0)
for times in range(1,5):
pool.append(a)
print pool
pool[1][2]='here'
print 'another'
print pool
输出:
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
another
[[0, 0, 'here', 0], [0, 0, 'here', 0], [0, 0, 'here', 0], [0, 0, 'here', 0]]
为什么改个元素会改4个数组里的数?