我試圖做Python中的嵌套的try/catch塊來打印一些額外的調試信息:Python嵌套try/except - 引發第一個異常?
try:
assert(False)
except:
print "some debugging information"
try:
another_function()
except:
print "that didn't work either"
else:
print "ooh, that worked!"
raise
我想總是重新引發第一個錯誤,但似乎這個代碼,以提高第二個錯誤(被認爲「沒有工作」的那個)。有沒有辦法重新提出第一個異常?
你想要做什麼? – karthikr