Python module,
Introduction:
Module: a collection of code that implements a function. There are three types:
- Custom Module
- Third-party module
- Built-in modules
Python to find the module path
Where, the third-party module installation location
Tip: The third-party module name cannot be the same as the built-in or third-party module name.
Import module: from lib. account import login
Add the sys. path:
OS module (related to the system)
OS. stat ("path") to get the file directory information
OS. path. dirname (path) Get the directory where the file is located
OS. path. exists (path) If path exists, true is returned; otherwise, false is returned.
OS. path. join (path1 [, path2 [,...]) returns the results after combining multiple paths. The parameters before the first absolute path are ignored.
Hashlib module: (encryption-related operations)
User name. The password must be encrypted
Md5 encryption cannot be reversed.
Because the md5 data on each computer is the same, the user name and password corresponding to the encryption will be obtained by others. Therefore, you must customize the data so that the data encrypted by md5 only exists on your computer.
Encrypted login registration instance:
Built-in modules
_ Doc _ is the comment of the py file
_ File _ # file path
_ Package _ under which folder the current py file is located, if multiple paths are connected.
_ Cached _ used for caching
_ Name _ (important)
_ Name _ = '_ main:
Main file: Before calling a function, add _ name _ = '_ main __'
Json serialization (Json is a string)
Json. loads is used to convert the list, dictionary, and tuples into corresponding dictionaries, lists, and tuples (note the error message and format)
The format of the note. An error is returned.
Json. dumps () converts the obtained dictionary, list, And tuples into corresponding strings.
Json. dump () Get the content and write it into the corresponding file.
Configparser module: (open and read files in specific formats) (default files are strings)
Shutil module (Advanced file, folder, and compressed Package Processing Module)
Subprocess Module
Logging module (important) (used to easily record logs and ensure thread security)