Python coding specification and python Encoding
I. Naming rules
1. The variable name, package name, and module name are usually in lower case and can be underlined.
2. The first letter of the class name is in upper case, and the object name is in lower case. The private variables and private methods of the class are prefixed with two underscores (_).
Example: class Student: # class Name
Student = Student ("ddd") # object
3. The function name is usually in lower case.
Example: def compareNum (num1, num2)
Ii. Code indent and colon
Code indentation refers to entering spaces and tabs before each line of code to indicate the hierarchical relationship between each line of code. Code indentation and colons are used to differentiate the layers between codes.
For example, if the code indentation is incorrect, the prompt is: IndentationError: expected an indented block.
Iii. Module Import
Import Module
Example: import sys
Iv. Code comments #
Support for Chinese annotations, usually at the top of the plus #-*-cpdomg: UTF-8 -*-
V. Statement Separation
1. Separate the statement by using a semicolon or line feed.
2. Python supports writing one statement in multiple lines
Example: SQL = "select id, name "\
"From dept "\
"Where name = 'A '"