我写了下面的代码:蟒蛇处理多例外
try:
do_somethong
except TimedOutException as e:
logger.exception(e)
except Exception as e:
logger.exception(e)
是这同下面的代码?
try:
do_somethong
except (TimedOutException, Exception) as e:
logger.exception(e)
我知道TimedOutException
是Exception
子类,我应该删除TimedOutException
?任何人都可以为我解释?提前致谢!
嗯我以不同的方式解释这个问题,但我明白你现在想说什么。 –
我会添加一些进一步的解释,使其更清晰。 – Adirio
如果我想在引发TimedOutException时重试,第一种方法更好,但是如果我只是在引发每个异常时打印错误消息,我可以使用'Exception Exception',不需要添加'TimedOutException' , 是对的? – pangpang