Python try except

后端 未结 5 1536
[愿得一人]
[愿得一人] 2021-01-19 00:12
try:
    #statement 1
    #statement 2
except Exception, err:
    print err
    pass

This may be very trivial but I never actually thought about it

5条回答
  •  遥遥无期
    2021-01-19 00:56

    Upon an exception being raised control leaves the try block at the point the exception is raised and is given to the appropriate except block. If statement 1 throws an exception, statement 2 will not execute.

    This answers your second question as well: it's not possible for the scenario you describe to happen.

提交回复
热议问题