Module overview
If the module is a logical way to organize Python code, then the file is the method of organizing the module on the physical layer.
Therefore, * * A file is considered to be a stand-alone module, and a module can also be considered as a file. The file name of the module is modulo
The name of the block plus the extension. py. Unlike other languages that can import classes (Class), in Python you are importing module or module attributes * *.
Module name space
A namespace is a relational mapping of a name to an object.
Import Module
Import module overall (import)
Way One
Copy Code code as follows:
Import Module1
Import Module2
...
Import Modulen
Mode two
Copy Code code as follows:
Import module1[, module2[,... Modulen]]
Import module properties (from ... import ...)
Call From-import can import the name into the current namespace, which means you do not need to use the attribute/Period attribute identifier to access the module's identifier. For example, you need to access the var name in module modules so that it is imported:
Copy Code code as follows:
From module import name1[, name2[,... Namen]]
Rename a module or property after import
Copy Code code as follows:
Import ... as .....
From ... import ... as ...
Package
The package is a hierarchy of file directory structure, the module corresponds to a single file, the package corresponds to a directory. As with classes and modules, packages also use the period attribute to identify the elements that they are asked to visit. Import the modules in the package using the standard import and From-import statements.