【发布时间】:2018-08-30 07:00:40
【问题描述】:
假设下面的代码。
try:
some_code_1
except: # will it be called twice, if an error occures in finally?
some_code_2
finally:
some_code_3
假设some_code_3 发生异常。我是否需要在 some_code_3 周围添加一个额外的 try-except 子句(见下文),还是会再次调用 some_code_2 的异常,这原则上可能导致无限循环?
这是保护程序吗?
try:
some_code_1
except: # will it be called twice, if an error occures in finally?
some_code_2
finally:
try:
some_code_3
except:
pass
【问题讨论】: