zoukankan      html  css  js  c++  java
  • Python handling an exception

    #try...except...
    try:
       You do your operations here;
       ......................
    except ExceptionI:
       If there is ExceptionI, then execute this block.
    except ExceptionII:
       If there is ExceptionII, then execute this block.
       ......................
    else:
       If there is no exception then execute this block. 
    
    #The except Clause with No Exceptions
    try:
       You do your operations here;
       ......................
    except:
       If there is any exception, then execute this block.
       ......................
    else:
       If there is no exception then execute this block. 
    
    #The except Clause with Multiple Exceptions
    try:
       You do your operations here;
       ......................
    except(Exception1[, Exception2[,...ExceptionN]]]):
       If there is any exception from the given exception list, 
       then execute this block.
       ......................
    else:
       If there is no exception then execute this block. 
    
    #The try-finally Clause
    try:
       You do your operations here;
       ......................
       Due to any exception, this may be skipped.
    finally:
       This would always be executed.
       ......................
    
    #Argument of an Exception
    try:
       You do your operations here;
       ......................
    except ExceptionType, Argument:
       You can print value of Argument here...
    

      

  • 相关阅读:
    你都这么拼了,面试官TM怎么还是无动于衷
    js中string转map的方法
    如何使用jmeter做一个功能的性能测试
    如何看待远程办公?
    vue.js指令v-for使用以及下标索引的获取
    v-charts x轴字体斜显示
    Linux-(inotify-tools&rsync)
    Linux-(type,vim)
    zab协议
    数据库的规范一览
  • 原文地址:https://www.cnblogs.com/KennyRom/p/6294536.html
Copyright © 2011-2022 走看看