你懂python吗(12) 发表于 2017-03-31 | 分类于 Python | python的拷贝1234567891011121314151617import copyif __name__ == '__main__': a=[1,2,3,[4,5,6]] b=a c=copy.copy(a) #浅拷贝 d=copy.deepcopy(a) #深拷贝 a.append(7) a[3].append(8) print 'a', a print 'b', b print 'c', c print 'd', d#outputa [1, 2, 3, [4, 5, 6, 8], 7]b [1, 2, 3, [4, 5, 6, 8], 7]c [1, 2, 3, [4, 5, 6, 8]]d [1, 2, 3, [4, 5, 6]] 如果对您有价值,看官可以打赏的!