标签:
1 #coding=utf-8 2 import copy 3 a=[1,2,‘a‘,‘ab‘,[‘c‘,‘d‘]] 4 b=a #只是传引用 5 6 c=copy.copy(a)#copy 7 d=copy.deepcopy(a)#deepcopy 8 9 a.append(‘f‘) 10 a[4].append(‘m‘) 11 12 print ‘a:‘,a 13 print ‘b:‘,b 14 print ‘c:‘,c 15 print ‘d:‘,d
1 Python 2.7.9 2 Type "copyright", "credits" or "license()" for more information. 3 >>> ================================ RESTART ================================ 4 >>> 5 a: [1, 2, ‘a‘, ‘ab‘, [‘c‘, ‘d‘, ‘m‘], ‘f‘] 6 b: [1, 2, ‘a‘, ‘ab‘, [‘c‘, ‘d‘, ‘m‘], ‘f‘] 7 c: [1, 2, ‘a‘, ‘ab‘, [‘c‘, ‘d‘, ‘m‘]] 8 d: [1, 2, ‘a‘, ‘ab‘, [‘c‘, ‘d‘]] 9 >>>
标签:
原文地址:http://www.cnblogs.com/linkong1081/p/python.html