Tag Archives: unindent does not match any outer indentation level

The solution to the problem of unified does not match any outer indentation level in pychar platform

Python has strict requirements for indentation

If you pay attention to it a little bit, you will get the error of unified does not match any outer indentation level


1. The indent before and after the code is inconsistent

You can see that there is a small red wavy line in front of def, which indicates that there is an indentation error here. Obviously, the indentation of the annotation in front of DEF is inconsistent with that of def (one is 2 and the other is 4). Just change it to be consistent

2. The indent before and after the code is inconsistent

In the figure above, the indent in front of the definitions of the two functions are the same, but an error prompt appears after x = 3, which indicates that an indent error has occurred near the sentence (before and after). Move the mouse to the highlighted yellow area or the red wavy line error area, and the error message will be displayed

From the error message, we can see that x = 3 does not match the following indentation. Further, we can see the prompt in the second figure: discontinuous indentation, tab indentation in the previous line, and sapce indentation in this line. Obviously, it is OK to change the indentation in front of def test2 to tab

Also, change the indentation before y = 3

3. Mixing tab and space

Obviously, if you use space and tab to indent in front of a piece of code, an error will naturally occur. At this time, pychar will automatically judge and adjust according to your preset indentation value

The indentation value you set is set in the settings above, which is generally 4, and the figure above is 3

If you open someone else’s Python program or Python script, it is very likely that there will be an indentation error. At this time, you only need to modify the indentation amount of the error place. Or use global substitution to replace spaces and indents in your code

Use the shortcut key of crtl + H to replace

In the figure above, replace tab (\ T) with four spaces. Note that you need to check the regex option when replacing symbols. The green area in the figure is tab area, and the yellow area is space area

undertake MATLAB, Python and C + + programming, machine learning, computer vision theory implementation and guidance, undergraduate and master can, please contact QQ 757160542 for details

This article shares in the blog “Yu Xiaoyong” (CSDN).