First: import library
-
Packet should be introduced in the following order:
-
Import Standard Library
-
Import-related third-party libraries
-
Local application / library specific import
-
You should be in each group adding blank lines between import.
- Less than the module, do not load within the module
-
-
Recommend using an absolute path to import, if not properly configured into the system (such as a table of contents in the bag after sys.path in the path), using an absolute path will be more readable and better performance (at least provide better error messages )
import json import os import time from threading import Thread from multiprocessing import Process import requests import acquire_all_gift_link from tools import read_cooks from tools import add_click import acquire_gift
Top-level function, top class, we need two blank lines
Internal method blank line.
End of the file to leave a blank line
Number = (equal sign) on both sides of an assignment statement has a space, if space is not required if parameter passing
==,!=,<,>,<=,>=
+ - * / // %
+= -=
& | ^
and or is in
Trailing spaces
',' ':' ';' (Commas, semicolons, semicolon) followed by a space
'' '' '' Belonging docstring explanatory notes, which can be written in the module, or may be written in the function inside the class.
List, Ganso, behind dictionary reserve (comma),
# Comment in front of at least two spaces followed by only one space
Global variables in all capital letters, underlined the connection between words.
Code length so as not more than 80 characters.
A function to do one thing
Reference link: https: //www.jianshu.com/p/ffcc66bab3ce
https://blog.csdn.net/ratsniper/article/details/78954852