如何在不需要操作时处理 Python 异常

How to handle Python exceptions when no action is desired

IN python下面的语法一般是处理异常的方式是SystemExit是可以的。

try:
    execute some command here
except SystemExit:
    take a different course of action here

但是,我想以一种不采取替代行动的方式使用异常处理。一般来说,我只想阻止 SystemExit 并继续执行程序。我尝试了以下方法,但它仅在 for 循环内有效

try:
    execute some command here
except SystemExit:
    continue

如何执行这个通用代码块?

尝试使用 pass 语句:

try:
    execute some command here
except SystemExit:
    pass