Problem
A python script, which would have run well, then wrote a few lines of code, and also ensured that each line was aligned, but when it ran, there was a syntax error:
Indentationerror:unindent does not match no outer indentation level
"Resolution Process"
1. The most common reason for this error is that there is indeed no alignment. But I'm going to look at the code based on the number of lines I've been wrong.
All with the TAB key, aligned well, there is no misaligned line number AH.
2. Think that the contents of the previous comment affect the syntax of the following statement, so the previous comment has also been deleted.
The result is still this syntax error.
3. After a long day of tossing, suddenly thought of, the current Python script all the characters are displayed to see if there are any special characters.
The currently used text editor notepad++, as if there is a setting that can display all the characters.
Found, in:
Show spaces and tabs, display symbols, view
Then you can see the problem:
The original error line number is 1580 rows:
But the source of the 1580 lines of the alignment with a dot point of space, and the previous lines of the alignment of the arrows used to indicate the TAB key, is mismatched, that is, the code alignment, mixed with the TAB key and space:
The new Python syntax, which is not supported by code alignment, is mixed with tab and space. So the above error message appears.
Knowing the reason, the solution is simple:
To the corresponding tab, are changed to a space, unified the style of alignment, you can.
In the notepad++, go:
Preferences, Settings:
Language--Replace with a Space (Tab key):
Can be implemented, for each subsequent tab input, are automatically converted to 4 spaces.
Summary
Python encountered Indentationerror, the first time to think, is not due to the TAB key and the use of space mix.
It is estimated that many people are also responsible for this kind of cause. Just remember to unify a bit.
Blog Original address: http://www.crifan.com/python_syntax_error_indentationerror/comment-page-1/
Syntax error in Python script run: Indentationerror:unindent does not match any outer indentation level (RPM)