First, what is the module
Common scenario: A module is a file that contains Python definitions and declarations, and the file name is the suffix of the module name plus the. Py.
In fact, the import loaded module is divided into four general categories:
1 code written using Python (. py file)
2 C or C + + extensions that have been compiled as shared libraries or DLLs
3 packages for a set of modules
4 built-in modules written and linked to the Python interpreter using C
Why use a module?
If you quit the Python interpreter and then re-enter, then the functions or variables you defined previously will be lost, so we usually write the program to a file so that it can be persisted and executed in Python test.py when needed, when test.py is called a scripting script.
With the development of the program, more and more functions, in order to facilitate management, we usually divide the program into a file, so that the structure of the program is clearer and easier to manage. At this point, we can not only use these files as scripts to execute, but also as a module to import into other modules, to achieve the reuse of functionality.
commonly used in relation to an operation is divided into different modules according to the correlation classification. Modules are also divided into three types: Built-in Module expansion Module custom module.
Python note Five (collections module)