How to deal with confusion about spaces and tabs in python in notepad++

When we write python code, we sometimes copy a piece of code from the Internet, as shown in the figure below, all of which exist in the form of spaces (for how to display these spaces, view -> display symbols -> display spaces and tabs)


But when we click the enter key to continue writing the code, there will be a situation where tabs and spaces are mixed, and an error will occur when running the code, such as (unindent does not match any outer indentation level)


Solution

Settings->Preferences->Language->Check Replace with spaces


This is when you press the enter key to continue writing the code, it becomes all the space bar. As long as the space bar and the tab key are not mixed, the program will not go wrong.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325801227&siteId=291194637