以下是我的一段代码:
def main(): num = 0 try: raise Exception('This is the error message.') except Exception: num += 1 return num finally: num += 1 a = main() print(a)
返回值为 1 而不是 2 ,这对我来说没有多大意义。
1
2
我以为它会返回2,因为最终应该在返回值之前执行。
有人能帮我理解吗?