"""" nonlocal 是一个关键字 用于在嵌套函数(即内部函数)中修改外层函数(非全局作用域)中的变量。 """ def fun1(): b = 100 def fun2(): nonlocal b b = 300 fun2() print(b) fun1()