zoukankan      html  css  js  c++  java
  • 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语句是最后一步总会执行的语句。

  • 相关阅读:
    .NetMVC过滤器
    Vue-cli配置
    回顾2019年到今天
    八皇后问题
    约瑟夫环问题
    斐波那契函数列
    提高学习效率的方法
    感受爱阅读笔记
    Android IO流汇总
    Android的AsyncTask
  • 原文地址:https://www.cnblogs.com/huclouy/p/6115829.html
Copyright © 2011-2022 走看看