1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| >>> import copy >>> a=[1,2,3,["a","b"]] >>> c=copy.copy(a) >>> print a;print c [1, 2, 3, ['a', 'b']] [1, 2, 3, ['a', 'b']] >>> a.append(5) >>> print a;print c [1, 2, 3, ['a', 'b'], 5] [1, 2, 3, ['a', 'b']]
>>> a[3] ['a', 'b'] >>> a[3].append('cccc') >>> print a;print c [1, 2, 3, ['a', 'b', 'cccc'], 5] [1, 2, 3, ['a', 'b', 'cccc']] 里面的子对象被改变了
|