Tag: is the name class written to test default Col div color
First, the module import
What is a module? In fact, the module is a py file.
There are several ways to import modules, different import methods, the use of functions in the module are not the same.
#1. Import Module Name:the calling method of the inside function, the module name. function name ()ImportTimetime.sleep (1)#2. Name of import function from module namefunction Call Method: function name () fromTimeImportSleepsleep (1)#3. From Module name import *function Call Method: function name () fromTimeImport*Sleep (1)#4. Import Module name as Aliasfunction Call Method: Alias. Function name ()ImportTime as Tt.sleep (1)
Next, let's introduce the __all__ variable. It is used as follows: adding __all__ to the module file is actually a list of the names of each function. When this module is called with the From module name import *, what functions are imported into __all__, and if __all__ is not defined, all functions are imported by default.
This is the test module
def PrintA (): Print ('AAAA') def printb (): Print ('BBBB') __all__=['printA']
Here is the call to test
from Import *PrintA () #AAAA# if called, PRINTB () error
What is a package?
The so-called package is actually a few py files, and contains a __init__ file.
Here's how to import packages:
# 1. From Package name import module name Call method: module name. function name ()#2, Import package name. module Name Calling method: Package name. module name. function name ()#3, from package name import Call method: module name. function name () Note: Use this if the __init __ File writes the __all__ variable, holds the module name to import, does not write the default nothing to import #4, the From Package name. module Name Import * Call Method: function name ()
Python module and Package entry method