a = 1print(id(a))def fun(a): a = 2 print(a,id(a))fun(a)print(a,id(a)) # 1#为什么这里的a的值没有改变#因为在函数里变量赋值(内存指向)作用于该函数 类似于局部变量#假如在函数里加个global a