def createCounter():
x=0
def counter():
nonlocal x
x=x+1
return x
return counter
f1=createCounter()
print(f1(),f1(),f1(),f1(),f1())
f2=createCounter()
print(f2(),f2(),f2(),f2(),f2())
Sign in to make a reply
.陈.
def createCounter():
x=0
def counter():
nonlocal x
x=x+1
return x
return counter
f1=createCounter()
print(f1(),f1(),f1(),f1(),f1())
f2=createCounter()
print(f2(),f2(),f2(),f2(),f2())