Notes on writing Python code

1. Indent

Students who are new to Python need to pay attention to the indentation of python. The official encourages the use of 4 spaces for indentation. At this time, you need to pay attention to the distinction between the Tab key and the space. Students using Notepad++ can tick Replace with spaces in Settings - Preferences - Tab Width. In this way, when writing code, using the Tab key is equivalent to four spaces. as the picture shows

2. Be careful not to use Chinese input method when writing code, otherwise a syntax error SyntaxError: invalid character in identifier will be reported

 

Guess you like

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