The Python module
A package is a folder, and a package can have multiple levels;
modules are xxx.py files, you can create your own modules, and import them, the module name is the same as the name of the file;
Python imports a module using the import statement.
Import Math
Print math.sqrt (+) # = 4
Only a few functions of the math module that you want to import
From math import ceil, floor
Print Ceil (3.7) # = 4.0
Print floor (3.7) # = 3.0
# import all definitions from the module
# Warning: deprecated
From Math Import *
Using the From...import import function Sometimes causes conflicts of the same name. At this point, you can give the function an " alias" to avoid conflicts ;
From math import logfrom logging import log as Logger # logging log now becomes Loggerprint log ( s) # called the lo of math Glogger (' Import from logging ') # called the log of logging
# You can also see what properties and methods are in the module using the Dir method
Import Math
Dir (Math)