當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python timeit.Timer.print_exc用法及代碼示例

用法:

print_exc(file=None)

從定時代碼打印回溯的助手。

典型用途:

t = Timer(...)       # outside the try/except
try:
    t.timeit(...)    # or t.repeat(...)
except Exception:
    t.print_exc()

與標準回溯相比的優勢在於,將顯示編譯模板中的源代碼行。可選的file 參數指示發送回溯的位置;它默認為 sys.stderr

相關用法


注:本文由純淨天空篩選整理自python.org大神的英文原創作品 timeit.Timer.print_exc。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。