A. py file is a module in which many functions can be defined, and functions can be loaded into a module. Modules also have Python built-in modules, and third-party modules, different modules can have the same function name and variable name, the module can be organized into the package, different package can have the same module name. Note that there must be a __init__.py file under any package, it can play the role of the compiler to identify the package, that is, it is the package!
As in the picture, you can also organize multi-level catalogs, in the MyCompany package, there are several modules in the web package = =, the figure has two __init__.py files, a corresponding Web package, a corresponding MyCompany package. Standard file module for Python modules.
#!/usr/bin/env python3
#coding:utf-8
‘ a test module‘
_author_=‘Tessie‘
The first line allows the. py file to be used directly on the Mac/linux/unix, and the 2nd line of comments indicates that the. py file itself uses standard UTF-8 encoding, and the third behavior document comment, the first string of any module is the document comment of the module. Line four uses the __author__ variable to write the author in, others can see your name! ~ Next is the coding section. For private functions and public functions, the private function is the use of this module, do not need to use this function, the private function service inside the module, and the public function can be called externally, that is, the public outside the main, private , which is used to coordinate various functions.
python--Module Micro-talk