def fun_out(data):
num = 100
#100
print("外层函数:", data, num)
def fun_in():
nonlocal num
num += 100
#200 300
print("内层函数:", num)
fun_in()
#200
print("外层调用内层后:", num)
return fun_in
func = fun_out(10)
func()
4.网络,web服务器——闭包,外层函数变量
最新推荐文章于 2024-11-02 23:18:49 发布