‘’‘闭包函数的具体细节’’’
def counter(start=0):
def infuc():
nonlocal start
start += 1
print(‘此时内部函数调用的结果是:’,start)
return infuc#返回内部函数
if name == ‘main’:
mycount = counter(4)
mycount()
‘’‘在python3中,用nonlocal进行环境变量的声明,再修改环境变量’’’
运行结果
python 装饰器 闭包函数的具体细节
猜你喜欢
转载自blog.csdn.net/weixin_44737399/article/details/89161798
今日推荐
周排行