Discuss / Python / 使用nonlocal的对我来说好理解

使用nonlocal的对我来说好理解

Topic source

Resalee

#1 Created at ... [Delete] [Delete and Lock User]
def createCounter():
    i = 0
    def counter():
        nonlocal i
        i = i+1
        return i
    return counter


  • 1

Reply