python-related knowledge

1, the control module
to execute: pip freeze> requirements.txt
then execute: pip install -r requirements.txt

2, the new python package and directory differences
directory: storage resource
python package: the method directory can be referenced

3, naming
constants: uppercase, if necessary, underlined, such as: THIS_IS_A_CONSTANT = 1
Common variables: lower case, if necessary, underlined, such as: this_is_a_variable = 1
private variable: the prefix is underlined
functions and methods: lower case, if desired underlined
categories: named camel, typically using large hump
modules: module name in lower case, underlined without
package: all lowercase, use underscores
file: lowercase, underscore may be used

4, when the file is created at the beginning of the comment py settings
File - Settings - Editor - File and Code Templates - Python Script
and written comments to the beginning

5, access to the project root directory

# Get the project root 
DEF the root_path (): 
    P = The os.getcwd () 
    the while True: 
        P = The os.path.split (P) 
        IF P [. 1] == '2020': 
            BREAK 
        the else: 
            P = P [0] 
    return p [0] + '\\ ' + p [1]

  

Guess you like

Origin www.cnblogs.com/yinwenbin/p/12228653.html