Similar to the C language function that includes header files to reference other files, python also has a similar mechanism. The commonly used introduction methods are as follows
import module name # The module name is the py file name # Use this method to use the module name when calling the function later. Function name() This form from module name import function name # When using this method, you can directly use the function name () form when calling the function later
The thing to note here is that
When the module and program entry are files of the same level, the above methods can be used
If it is not the same level file, it needs from package name (folder name) import module name (file name)
For example, how to introduce modules when multiple packages are nested
from package1.package2.package3 import module1 #Use this method to use the module name when calling the function later. Function name() This form from package1.package2.package3.module1 import func #When using this method, you can directly use the function name () form when calling the function later