利用闭包返回一个计数器函数,每次调用它返回递增整数
def createCounter(): n = 0 def counter(): nonlocal n n+=1 return n return counter# 测试:counterA = createCounter()print(counterA(), counterA(), counterA(), count...