出于某种原因,我的代码在抛出异常时没有捕获异常。我有
def trim_rad(rad):
...
if not modrad.shape[0]:
raise IndexError("Couldn't find main chunk")
return modrad, thetas
然后稍后我调用该函数:
try:
modrad, thetas = trim_rad(rad)
except IndexError("Couldn't find main chunk"):
return 0
然而,我仍然得到那个例外的回溯。我究竟做错了什么?