1. Colon: Always remember to enter ":" At the end of the first line of the compound statement (if, while, for, and so on)
2. Blank lines are important at the interactive mode prompt. Blank lines within a compound statement in a module file are ignored, but when you enter code at the interactive mode prompt, the blank line is the closing sentence. “...”
3, indentation to be consistent. Avoid mixing tabs and spaces in block indentation unless you know how the text editor handles tabs. Otherwise, if the editor is counting tabs as spaces, what you see in the editor is not necessarily what Python sees.
4. Do not write C code in Python. When you write the IF and while first line, you do not have to test both sides of the input brackets (for example, if (x==1);), do not use semicolons to grow all the statements. Do not embed an assignment statement in a while loop test, and do not use {} around the block, instead using a consistent indentation of the nested program code block.
5. Use a simple for loop, not a while or range. Because Python handles index operations internally for a simple for loop, it is sometimes twice times faster than the equivalent while.
6. Do not expect the function that modifies the object in its original place to return the result. For example, the List.append and List.sort methods have no return value (except none) for this kind of modification operation. So don't write a statement like Mylist=mylist.append (x)
7. Be sure to call the function with parentheses. If closing the file is not file.close but File.close ()
8. Do not use extensions or paths in import and overloading. such as import mod instead of import mod.py
A mistake that Python beginners make easy