情况一: a 直接引用外部的,正常运行 def toplevel(): a = 5 def nested(): print(a + 2) # theres no local variable a so it prints the nonlocal one nested() return a 情况二:创建local 变量a,直接打印,正常运行 def toplevel(): a = 5 def nested(): a = 7 # create a local variable called a w…