x = 10 print(id(x)) x = 20 print(id(x)) 1646651456 1646651616 x = 10.1 print(id(x)) x = 20.1 print(id(x)) 21905056 21902576 x = ‘xxq‘ print(id(x)) x = ‘zsy‘ print(id(x)) 59860800 59862464
# l = [‘aaa‘,‘bbb‘,‘ccc‘] # print(id(l)) # l = [‘xxx‘,‘yyy‘,‘zzz‘] # print(id(l)) l = [‘aaa‘,‘bbb‘,‘ccc‘] print(id(l)) l[0] = ‘AAA‘ # print(l) print(id(l))
dic = {‘k1‘:111,"k2":222} print(id(dic)) dic[‘k1‘] = 333 print(id(dic)) 定义:{}内用逗号隔开多个 key : value,其中 value可以是任意类型,但是 key必须是不可变类型
原文:https://www.cnblogs.com/Tornadoes-Destroy-Parking-Lots/p/12433374.html