非局部变量>缩进错误:应为缩进块



这是我的代码:


  • def **make_Print_Driver_singelton_class**(): 
      counter=0 
      def **setcount**(): 
      nonlocal counter counte+=1
    

我得到这个错误:

nonlocal counter
       ^
IndentationError: expected an indented block

问题出在哪里?

我认为代码存在缩进问题。

def **make_Print_Driver_singelton_class**():
  counter=0
    def **setcount**(): 
      nonlocal counter
      counte+=1

最新更新