IndentationError: unexpected indent python

Detailed map traversal, teach you to master the complex gremlin query debugging method>>>

We all know that Python is very strict with the format requirements. I wrote some python, but I didn’t find out where it is strict. Today, I met the inditionerror: unexpected indent error, so I know how strict it is
when you encounter an indentation error: unexpected indent later, you should know that the python compiler is telling you “Hi, man, there is something wrong with the format of your file. It may be that the tab and space are not aligned. You need to check the tab and space.” first Cd ~ (to your home directory)
then LS – A (show hidden file)
find. Vimrc (remember it has a dot prefix)
then edit this file
find the following command:
16 set autoindent
17 set smart
19 set tabtop = 4
20 set shiftwidth = 4
21 set softtabstop = 4
22 set noexpandtab
then set tabtop = 4
in the =Add set expandtab before 4. At the same time, you need to comment out the set noexpandtab. How to comment is to add double quotation marks. I haven’t tried to comment directly without adding set expandtab. I think it’s OK. So you can use VIM safely
of course, I don’t want to finish it like this. In fact, I want to see what’s wrong with my code. I need to see its format, mainly tab. This can be set in the same file just now. For example,
add a set list under set softtabstop = 4. This sentence can make the file opened by your VIM display a tab. Of course, you may think that the display is not good-looking. It shows “^ I”, the symbol on a number key 6 and an uppercase I represent a tab. This will not display spaces. It also shows the start character ^ and the end character $. If you don’t know these two symbols, you can see the regular expression
after setting the above two points, I don’t think you will encounter the annoying error of indentation error: unexpected indent in the future
all of the above set commands can be used alone, but they are only valid for the currently opened vim. You can press shift and colon, then enter set XXX, and press enter to have the effect, but you need to enter edit mode again to see it
I hope to share it with everyone who writes python

Similar Posts: