Article Directory
1. Introduction
Today, I used Python to write a program in the Raspberry Pi, and an TabError: inconsistent use of tabs and spaces in indentation
error was reported when it was running , which was resolved after consulting, so it was recorded.
Second, the cause of the error
This error is actually very common. It is nothing more than the use of spaces when the tab key is used to align. Generally speaking, using 4 spaces is equivalent to a Tab key, but there are different opinions in different compilers, so I suggest you To unify, either use all spaces or use the Tab key. For learning about code specifications, you can refer to the "Alibaba Coding Standards" to develop a good code writing standard, which is one of the indispensable means to enter a large factory. , As Mr. Lei said, write the code like "poem".
Three, the solution
First open the code file you wrote with Sublime, click on the top navigation bar Preferences->Setting, my Sublime let me Chinese, so the display is Chinese.
After opening, it will be "draw_white_space": "all",
copied to your own configuration.
Back to the original file, it is clear whether it is the Tab key or the space. The dot represents the space, and the horizontal line represents the Tab. We only need to unify the unification to it.