考虑以下代码:
try:
raise Exception("a")
except:
try:
raise Exception("b")
finally:
raise
这将引发 Exception: a
。我希望它会引发 Exception: b
(需要我解释为什么吗?)。为什么最后的 raise
引发原始异常,而不是(我认为)是最后引发的异常?
最佳答案
Raise is re-raising the last exception you caught, not the last exception you raised
(为了清楚起见,从评论中重新发布)
关于python - Python 中的 raise 会提高什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3935603/