python 中的 try/except/else/finally语句

1.python中try/except/else/finally正常的语句是这样的:

  try:

    normal excute block

  except A:

    Except A handle

  except B:

    Except B handle

  except:

    other exception handle

  else:

    if no exception,get here

  finally:

    print(hello world)

  说明:

    正常执行的程序在try下面执行normal excute block执行块中执行,在执行中如果发生了异常,则中断当前normal execute block 调到异常处理中开始执行,如果没有异常则会执行else中的语句(前提是有else语句),finally语句是最后一步总会执行的语句。

原文地址:https://www.cnblogs.com/huclouy/p/6115829.html