那是因为你要回来,除了街区 使用返回字将结束此函数中的代码执行。 为了避免这种情况,你可以这样写:
def main(): num = 0 try: raise Exception('This is the error message.') except Exception: num += 1 finally: num += 1 return num a = main() print(a)