traceback模块被用来跟踪异常返回信息. 如下例所示:
1
2
3
4
5
|
import
traceback
try
:
raise
SyntaxError,
"traceback test"
except
:
traceback.print_exc()
|
1
2
3
4
|
Traceback (most recent call last):
File "H:PythonWorkSpaceTestsrcTracebackTest.py", line 3, in <module>
raise SyntaxError, "traceback test"
SyntaxError: traceback test
|