def createCounter():
i = 0
def counter():
nonlocal i
i += 1
return i
return counter
还有一种采用list的方法
L = [0]
L[0] += 1
return L[0]
Sign in to make a reply
winner丶John
def createCounter():
i = 0
def counter():
nonlocal i
i += 1
return i
return counter