Python 非局部变量->;缩进错误:应为缩进块
这是我的代码:Python 非局部变量->;缩进错误:应为缩进块,python,python-3.x,Python,Python 3.x,这是我的代码: 我得到这个错误: nonlocal counter ^ IndentationError: expected an indented block 问题是什么?我认为代码有缩进问题 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
是什么阻止你修复缩进?我不知道问题是什么错误信息中提到的问题。你仔细看了吗?我不明白是什么问题。我的英语不是很好,python对我来说也很陌生。拿你擅长的任何语言的python手册,读几章。那么你一定会明白问题是什么。你问的是语言的基础知识……这是一个非常糟糕的答案,因为代码没有格式化,你没有说OP做错了什么以及如何修复它。
def **make_Print_Driver_singelton_class**():
counter=0
def **setcount**():
nonlocal counter
counte+=1