Discuss / Python / 作业打卡

作业打卡

Topic source

无虑43793

#1 Created at ... [Delete] [Delete and Lock User]

nonlocal很重要,不然会报变量作用域的错可以以重新定义变量

def createCounter(): he=0 def counter(): nonlocal he he +=1 return he return counter


  • 1

Reply