Attribute Meaning  
__doc__ The function’s documentation string, or None if unavailable; not inherited by subclasses Writable
__name__ The function’s name Writable
__qualname__

The function’s qualified name

New in version 3.3.

Writable
__module__ The name of the module the function was defined in, or None if unavailable. Writable
__defaults__ A tuple containing default argument values for those arguments that have defaults, or None if no arguments have a default value Writable
__code__ The code object representing the compiled function body. Writable
__globals__ A reference to the dictionary that holds the function’s global variables — the global namespace of the module in which the function was defined. Read-only
__dict__ The namespace supporting arbitrary function attributes. Writable
__closure__ None or a tuple of cells that contain bindings for the function’s free variables. Read-only
__annotations__ A dict containing annotations of parameters. The keys of the dict are the parameter names, and 'return' for the return annotation, if provided. Writable
__kwdefaults__ A dict containing defaults for keyword-only parameters. Writable

获取当前的代码所在的文件名

__globals__['__file__']
D:\MARK\NOTE\temp.py

相关文章:

  • 2021-06-07
  • 2022-01-03
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-13
猜你喜欢
  • 2021-09-09
  • 2022-12-23
  • 2021-08-15
  • 2022-01-27
  • 2021-05-19
  • 2021-08-17
相关资源
相似解决方案