參考:http://thomaschen2011.iteye.com/blog/1441254 Python基礎:Python可變對象和不可變對象
http://blog.jobbole.com/49705/ Python 中的 is 和 id
Python在heap中配置設定的對象分成兩類:可變對象和不可變對象。所謂可變對象是指,對象的内容是可變的,例如list。而不可變的對象則相反,表示其内容不可變。
不可變對象:int,string,float,tuple
可變對象 :list,dictionary
個人注解:
通過 id(objVar) 函數 檢視對象的記憶體位址。
對可變對象修改時,要明确 是否 儲存舊的資料,如果不儲存的話,需要先拷貝: obj.copy()