Home > Article > Backend Development > Python问题1:IndentationError:expected an indented block
The Python language is a language that is very sensitive to indentation, which has caused confusion to many beginners. Even experienced Python programmers may fall into traps. The most common situation is that the mixed use of tabs and spaces will lead to errors, or incorrect indentation, which cannot be distinguished with the naked eye.
This error will occur during compilationIndentationError:expected an indented blockIndicates that indentation is required here. You only need to press space or Tab ( But you can't mix them) key indentation will do.
Some people often wonder: Why am I still wrong even if I don’t indent at all? That’s not right. I should indent where I should. If I don’t indent, I will make an error. For example:
if xxxxxx:
(space)xxxxx
or
def xxxxxx:
(space)xxxxx
besides
for xxxxxx:
(space)xxxxx
In one sentence, the next line with a colon often needs to be indented, and the indentation should be indented
The above is the detailed content of Python问题1:IndentationError:expected an indented block. For more information, please follow other related articles on the PHP Chinese website!