我正在尝试以以下方式捕获 SystemExit
异常:
try:
raise SystemExit
except Exception as exception:
print "success"
但是,它不起作用。
但是,当我像这样更改我的代码时,它确实起作用:
try:
raise SystemExit
except:
print "success"
据我所知,
except Exception as exception
应该可以捕获任何异常。这也是这里所描述的方式。为什么在这里它不起作用呢?