One, print (VARs ()) output results are as follows:
{' __name__ ': ' __main__ ',
' __doc__ ': None,
' __package__ ': None,
' __loader__ ': <_frozen_importlib_external. Sourcefileloader object at 0x0000014be5cba470>
' __spec__ ': None,
' __annotations__ ': {},
' __builtins__ ': <module ' builtins ' (built-in);
' __file__ ': ' e:/python_code/2/13day/index.py ',
' __cached__ ': None}
Among the more commonly used are:
__doc__ print a file comment, the contents of the three quotation marks at the beginning of the. py file
__file__ to print the full path name of the current PY file
__PACKAGE__ the package where the import file is located, that is, the folder name where the py file is imported, and the folder hierarchy. Interval, such as Lib.test
__cached__ Python3, the full path of the. pyc file that the cache file, import file executes.
__NAME__ returns __main__ if the current py file is running, returns the folder path where the current import file resides if another file import runs
Therefore, in order to prevent the import of modules to run directly, you can use __name__ = = __main__ to judge:
"Python Route 27" VARs () contains the global variable object