在python中声明全局变量可以使用关键字global,那么如何声明方法级之间的变量就需要用到nonlocal
# coding=utf-8
def change():
name = "wang"
print(name)
print(id(name))
def lear():
nonlocal name
name ="nie"
print(name)
print(id(name))
lear()
print(name)
print(id(name))
if __name__ == '__main__':
change()