我有代码:
try:
print test.qwerq]
try:
print test.sdqwe]
except:
pass
except:
pass
Run Code Online (Sandbox Code Playgroud)
如何在嵌套try中打印所有错误的调试信息?
重新提出异常.
try:
print test[qwerq]
try:
print test[qwe]
except:
# Do something with the exception.
raise
except:
# Do something here too, just for fun.
raise
Run Code Online (Sandbox Code Playgroud)
应该注意的是,一般来说你不想这样做.如果你不打算对它做任何事情,你最好不要捕捉异常.
如果您只想打印调用堆栈而不是崩溃,请查看traceback模块.
| 归档时间: |
|
| 查看次数: |
613 次 |
| 最近记录: |