首页 > 编程语言 > 详细

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

时间:2016-11-30 02:39:29      阅读:236      评论:0      收藏:0      [点我收藏+]

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语句是最后一步总会执行的语句。

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

原文:http://www.cnblogs.com/huclouy/p/6115829.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!