Import module fromimport module
What is the difference between the above code?
From module Import * This kind of import imagination and the code inside the module is copied into the current module (that is, the location of the statement), you can directly use the module inside the variable name and method, etc.
So this approach does not take effect if the variables and methods have the same name as the current module.
Import Module If you use variables or methods inside, you must prefix the module name. The essence of import is to explain the module in advance and assign it to a module with the same name
variables, so that's why you use modules or variables inside to add the module name.
"Package" can be imported because it has a __init__.py file, so the process of importing the package is to explain the process of the file. Before executing this file, however, it is the first to search
Find out where this bag is? Just go sys.path the search path defined in this definition. This first contains the current pavement, the project's Sources roots directory, and other system-built paths. So Sys.path
This is the list, and if you sometimes can't find the package you imported, you can add the package path to the Sys.path list. The first element in a Sys.path list is always the current path.
Although the import Package and Import module are import statements but the logic behind it is not, the import package is the execution package under the __init__.py, but the import module is to copy the contents of the module to the same name of the module
becomes a variable.
Look at the following example
Import instructions for Python packages