PythonStudy——可变与不可变 Variable and immutable

ls = [10, 20, 30]
print(id(ls), ls)
ls[0] = 100
print(id(ls), ls)

print(id(10))
print(id(20))
print(id(100))
print(id('100'))

       

                               可变指的是:数据类型的引用地址可变,直接在堆区数据区对原数据直接操作

 

PythonStudy——可变与不可变 Variable and immutable

                         

                 不可变指的是:数据类型的应用地址不可变,需要重新创建与原数据一致的数据进行间接操作。

PythonStudy——可变与不可变 Variable and immutable

     

 

        参考链接:https://www.cnblogs.com/Jacck/p/7790049.html