# 深浅拷贝
ls = [1, 2, 3, ['python', 'java']]
dt = {
'info1': {'id' : 1, 'user' : 'root'},
'info2': {'id' : 2, 'user' : 'admin'}
}
ls_new = ls.copy()
dt_new = dt.copy()
ls_new[3][0] = 'python3'
dt_new['info1']['user'] = 'admin'
print(ls)
print(dt)
import copy
ls_new = copy.deepcopy(ls)
dt_new = copy.deepcopy(dt)
ls_new[3][0] = 'python3'
dt_new['info1']['user'] = 'admin'
print(ls)
print(dt)
标签:深浅,ls,print,new,拷贝,copy,dt,user
From: https://www.cnblogs.com/hacker-dvd/p/17527684.html