Python strings, 元组tuples, 和numbers是不可更改的对象,而list,dict等则是可以修改的

在python中,strings, 元组tuples, 和numbers是不可更改的对象,而list,dict等则是可以修改的对象。

a = 1

def fun(a):
    a = 2
fun(a)
print a  # 1
 
a = []
def fun(a):
    a.append(1)
fun(a)
print a  # [1]
 
https://github.com/taizilongxu/interview_python
原文地址:https://www.cnblogs.com/xuxueqin/p/8065666.html