标签:python
深浅拷贝概述:浅拷贝:只拷贝一层;
深拷贝:相当于克隆一份;
import copy husband = ['xiaohu',123,[15000,9000]] wife =husband.copy() wife[0] = 'xiaopang' wife[1] =345 print(wife) ['xiaopang', 345, [15000, 9000]] xiaosan =copy.deepcopy(husband) xiaosan[0] = 'xiaojin' xiaosan[1] = 668 xiaosan[2][1] -= 1999 print(xiaosan) ['xiaojin', 668, [15000, 7001]]
标签:python
原文地址:http://blog.51cto.com/11518612/2086955