闭包的二次学习
作者:互联网
def func(): # 定义函数func() a = 10 i = 0 def inner(): # 定义函数inner() nonlocal a, i a = a + 1 i = i + 1 print("第%s次执行所得结果是:" % i, end="") return a # 函数inner的返回值 return inner # 函数func的返回值 ret = func() r1 = ret() print(r1) r2 = ret() print(r2)
标签:闭包,函数,r2,二次,ret,学习,inner,func,print 来源: https://www.cnblogs.com/acwecc/p/16333937.html