# 自增闭包函数 def createCounter(): i = 0 def counter(): #Python 3.x可以声明变量i为局部变量 nonlocal i i = i + 1 return i return counter
Sign in to make a reply
gitKong