A .import
-
When import imported module name defined need.
For example, we first create a md.py file, which has a function
-
Then reference this function in 1.py file.
Note that we need to use md. Way call. Module name if not defined, will be given
-
For example, this way, we get rid of the qualified name of the module, on the error
END
二.from...import
-
from md import * mean, imported all the modules.
We can import only the specified portion of the current namespace.
As shown below, we have modified the md module, which has three functions
-
We modified the 1.py file and import function of the two of them. Seen on the results, the last sentence of the error. Because we do not have to import all the files, import only the two functions only.
-
We now add a file md2.py, which wrote a function of alsp
-
We 1.py while quoted md and md2 module, use from import way
-
Results are as follows, the second sentence of a first import cover, the second sentence is executed md2 function module alsp