Discuss / Python / homework

homework

Topic source

gitKong

#1 Created at ... [Delete] [Delete and Lock User]
# 自增闭包函数
def createCounter():
    i = 0
    def counter():
        #Python 3.x可以声明变量i为局部变量  
        nonlocal i
        i = i + 1
        return i
    return counter

  • 1

Reply