python深拷贝浅拷贝

来源:互联网 发布:c语言float怎么定义 编辑:程序博客网 时间:2024/05/15 18:07
http://blog.csdn.net/echoutopia/article/details/51725430
import copya = [1,2,3,4,5,[6,7,8]]b = a[:]c = ad = copy.deepcopy(a)e = copy.copy(a)print "id of a :",id(a)print "id of b :",id(b)print "id of c :",id(c)print "id of d :",id(d)print "id of e :",id(e)print "\n"print "id of a['5'] :",id(a[5])print "id of b['5'] :",id(b[5])print "id of c['5'] :",id(c[5])print "id of d['5'] :",id(d[5])print "id of e['5'] :",id(e[5])



id of a : 140182194535024id of b : 140182194565416id of c : 140182194535024id of d : 140182194581232id of e : 140182194392960id of a['5'] : 140182194947208id of b['5'] : 140182194947208id of c['5'] : 140182194947208id of d['5'] : 140182194565344id of e['5'] : 140182194947208


0 0