Python Hidden variables
__doc__ # Indicates comments in this document
__FILE__ # Indicates the path to this file
__PACKAGE__ # The folder path where the imported py file is located
__CACHED__ # Cache of import files
__name__ #如果是主文件 __name__ = "__main__" otherwise equals function name
#!/usr/bin/env python#-*-coding:utf-8-*-"""{' __builtins__ ': <module ' builtins ' (built-in);, ' __package__ ': None, ' __cached__ ': none, ' __file_ _ ': ' c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py ', ' __doc__ ': None, ' __name__ ': ' __main__ ', ' __loader__ ': <_frozen_importlib_external. Sourcefileloader object at 0x0000026ec5a58978>, ' __spec__ ': None}"""if __name__=='__main__': Print(__file__) Print(__doc__) Print(VARs ())
Operation Result:
c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py # __file__{# __doc__'__builtins__': <module'Builtins'(built-inch) >, '__package__': None,'__cached__': None,'__file__':'c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py', '__doc__': None,'__name__':'__main__', '__loader__': <_frozen_importlib_external. Sourcefileloader Object at 0x0000026ec5a58978>, '__spec__': None}
# VARs () {'__cached__': None,'__package__': None,'__doc__':"\n{\n ' __builtins__ ': <module ' builtins ' (built-in), \ n ' __package__ ': none,\n ' __cached__ ': none,\n ' __file__ ': ' c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py ', \ n ' __doc__ ': None, \ n ' __name__ ': ' __main__ ', \ n ' __loader__ ': <_frozen_importlib_external. Sourcefileloader object at 0x0000026ec5a58978>,\n ' __spec__ ': none}\n",'__builtins__': <module'Builtins'(built-inch);'__file__':'c:/users/administrator/pycharmproject/myproject/myfunc/ceshi.py','__loader__': <_frozen_importlib_external. Sourcefileloader object at 0x000002354bfb8978>'__spec__': None,'__name__':'__main__'}
Python built-in variables