Module
The function of a module is to reuse code blocks, such as functions, properties, and classes.
Import Module
The import of a module is imported once, and a. pyc file is generated after the first import, and if it is imported again, Python imports the. pyc file instead of the. py file, unless the. py file has changed, in which case a new. pyc file is generated.
Custom Modules
The custom module is simple, save your own module as a python file at the end of the. Py, put it in a path that the Python interpreter can identify, and we can view the Sys.path path through the
It is customary for us to place the module in the Site-packages directory, and the other is to tell the compiler where to find the module we define, and we can include in the PYTHONPATH environment variable The directory information where the module resides: Edit or create a new user variable in the environment variable's page. The variable is named Pythonpath, the path is a variable value, and multiple values are separated by semicolons.
Package
To organize the modules, you can group them into packages, which are another type of module. In order for Python to treat the directory/file containing the module as a package, it must contain a module named __init__.py.
In order to place the module in the package, put the module directly in the package directory.
Python Learning Notes (iii)