When using import to import a module, the module name is the Python file name, removing the suffix. py.
When importing a module, the program in this module will be executed, but it will only be executed during the first import. If it is re-imported later, it will not be executed. If it needs to be re-executed, you can call the built-in function reload ().
If you want a program in the Python file not to be executed when the file is imported as a module, you can place the program in the if statement below:
If _ name _ = '_ main __':
In this way, only when the file is executed in an independent program will the programs in if be executed. This is because each file has a built-in attribute _ name __. if the file is executed in an independent program, _ name _ is set to '_ main __', if the file is imported as a module, _ name _ is set to the module name.
To introduce non-standard modules, run the following command to install them (for Ubuntu ):
Apt-get install python-tkapt-get install python-mysqldbapt-get install python-numpyapt-get install python-scipyapt-get install python-matplotlib