局部变量,全局变量,赋值相互独立
names = ['Lilei','Jcak']
def change_name():
names = ['Lilei','Hi']
print(names)
change_name() #['Lilei','Hi']
print(names) #['Lilei','Jcak']
修改列表里面的元素,调用的names与全局names为同一内存地址
names = ['Lilei','Jcak']
def change_name():
names[1] = 'Hi'
print(names)
change_name() #['Lilei','Hi']
print(names) #['Lilei','Hi']
小结:列表、字典、集合同理,元组里面的列表。。。也可以改