Distinguish between directories and packages :
If you have this document , It's just a bag ; If there is no , That's the catalog .
modular :xxxx.py file
A variable with the same name as a global variable in a function becomes a local variable
To reference a global variable , The function must be modified
Local namespace :
Global namespace :
locals() read-only
globals() read-write
1)
2)
The module name you want to import is too long
names
There is another import method ( Dynamic import )
It's fine too :
from package import moudule
When this package When it comes to hierarchical packages , To write out the parent package .
Import a variable from another module , It can also be nicknamed
The code of the imported module will also be executed
When importing multiple variables , It can be enclosed in brackets , Line break . So that we don't make a mistake .
It can also be used. * To import all variables
Displays the name of the current module in the execution project , If the current program is running in this module , This module is called _main_
if name=="main" Generally refers to the entrance where the whole project starts to operate
Determine whether it is in this module , if , The output ……, otherwise , Output the name of this module