python学习Day9-赋值结构
内存指向(id)
传值,只想同一个值的内存空间
tang = 100
kai = tang
id(tang)
140706107531168
id(kai)
140706107531168
kai is tang
True
kai = 102
id(kai)
140706107531232
kai is tang
False
赋值,指向新的内存空间
tang = 1000
kai = 1000
id(tang)
1819631143248
id(kai)
1819631143216
kai is tang
False
赋值重用,节省内存,将简单或比较小的值重用
tang = 1
kai = 1
id(tang)
140706107528000
id(kai)
140706107528000
kai is tang
True
未完待续