python学习——闭包

def outer():

  a = 10

  def inner():

    print(a)

  return inner

ret = outer()#这种写法只加载了一次外层函数,所以执行的时候a = 10 只执行了一次

ret()

ret()

原文地址:https://www.cnblogs.com/bilx/p/11325133.html