nonlocal很重要,不然会报变量作用域的错可以以重新定义变量
def createCounter(): he=0 def counter(): nonlocal he he +=1 return he return counter
Sign in to make a reply
无虑43793
nonlocal很重要,不然会报变量作用域的错可以以重新定义变量
def createCounter(): he=0 def counter(): nonlocal he he +=1 return he return counter