Python 執行時服務¶
本章描述的模組提供了與 Python 直譯器及其與環境的互動相關的廣泛服務。這是一個概述
sys
— 系統特定的引數和函式abiflags
addaudithook()
argv
audit()
base_exec_prefix
base_prefix
byteorder
builtin_module_names
call_tracing()
copyright
_clear_type_cache()
_clear_internal_caches()
_current_frames()
_current_exceptions()
breakpointhook()
_debugmallocstats()
dllhandle
displayhook()
dont_write_bytecode
_emscripten_info
pycache_prefix
excepthook()
__breakpointhook__
__displayhook__
__excepthook__
__unraisablehook__
exception()
exc_info()
exec_prefix
executable
exit()
flags
float_info
float_repr_style
getallocatedblocks()
getunicodeinternedsize()
getandroidapilevel()
getdefaultencoding()
getdlopenflags()
getfilesystemencoding()
getfilesystemencodeerrors()
get_int_max_str_digits()
getrefcount()
getrecursionlimit()
getsizeof()
getswitchinterval()
_getframe()
_getframemodulename()
getobjects()
getprofile()
gettrace()
getwindowsversion()
get_asyncgen_hooks()
get_coroutine_origin_tracking_depth()
hash_info
hexversion
implementation
int_info
__interactivehook__
intern()
_is_gil_enabled()
is_finalizing()
last_exc
_is_interned()
last_type
last_value
last_traceback
maxsize
maxunicode
meta_path
模組
orig_argv
path
path_hooks
path_importer_cache
platform
platlibdir
prefix
ps1
ps2
setdlopenflags()
set_int_max_str_digits()
setprofile()
setrecursionlimit()
setswitchinterval()
settrace()
set_asyncgen_hooks()
set_coroutine_origin_tracking_depth()
activate_stack_trampoline()
deactivate_stack_trampoline()
is_stack_trampoline_active()
_enablelegacywindowsfsencoding()
stdin
stdout
stderr
__stdin__
__stdout__
__stderr__
stdlib_module_names
thread_info
tracebacklimit
unraisablehook()
version
api_version
version_info
warnoptions
winver
_xoptions
sys.monitoring
— 執行事件監控sysconfig
— 提供對 Python 配置資訊的訪問builtins
— 內建物件__main__
— 頂層程式碼環境warnings
— 警告控制dataclasses
— 資料類contextlib
—with
語句上下文的實用工具abc
— 抽象基類atexit
— 退出處理程式traceback
— 列印或檢索堆疊回溯__future__
— 未來語句定義gc
— 垃圾收集器介面enable()
disable()
isenabled()
collect()
set_debug()
get_debug()
get_objects()
get_stats()
set_threshold()
get_count()
get_threshold()
get_referrers()
get_referents()
is_tracked()
is_finalized()
freeze()
unfreeze()
get_freeze_count()
garbage
callbacks
DEBUG_STATS
DEBUG_COLLECTABLE
DEBUG_UNCOLLECTABLE
DEBUG_SAVEALL
DEBUG_LEAK
inspect
— 檢查活動物件- 型別和成員
getmembers()
getmembers_static()
getmodulename()
ismodule()
isclass()
ismethod()
isfunction()
isgeneratorfunction()
isgenerator()
iscoroutinefunction()
markcoroutinefunction()
iscoroutine()
isawaitable()
isasyncgenfunction()
isasyncgen()
istraceback()
isframe()
iscode()
isbuiltin()
ismethodwrapper()
isroutine()
isabstract()
ismethoddescriptor()
isdatadescriptor()
isgetsetdescriptor()
ismemberdescriptor()
- 檢索原始碼
- 使用 Signature 物件內省可呼叫物件
- 類和函式
- 直譯器堆疊
- 靜態獲取屬性
- 生成器、協程和非同步生成器的當前狀態
- 程式碼物件位標誌
- 緩衝區標誌
- 命令列介面
- 型別和成員
site
— 站點特定的配置鉤子