标签:str copy strong class deepcopy span 一个 div imp
s = [1,‘1230‘]
s2 = s #两个变量指向同一片内存
实例:银行中,一对夫妻两个账户,但钱是从一个地方取 husband = [ ‘xiaohu‘,123,[15000]] #余额 wife = husband.copy() #相当于副卡 wife[0] = ‘xiaomei‘ #账户名 wife[1] = 456 #卡号
import copy #xiaosan = copy.copy(husband) #浅拷贝 xiaosan = copy.deepcopy(husband) xiaosan[0] = ‘xiaomaomi‘ xiaosan[1] = 789 xiaosan[2][0] -= 1200 #操作不影响主卡
标签:str copy strong class deepcopy span 一个 div imp
原文地址:https://www.cnblogs.com/5014sy/p/9773750.html