school = ‘bei feng‘#全局变量
def change(name):
global school #声明更改全局变量
school = ‘Linux mage‘
print(‘before change‘,name,school)
name = ‘liuhao‘#局部变量,只在函数里面生效。这个函数就是局部变量作用域
print(‘before change‘,name)
name = ‘liucheng‘
change(name)
print(name,school)
原文:https://www.cnblogs.com/anhao-world/p/12873008.html