Python handling an exception「建议收藏」

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...

  

转载于:https://www.cnblogs.com/KennyRom/p/6294536.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/108689.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 移动终端处理器构成和基带芯片概述「建议收藏」

    移动终端处理器构成和基带芯片概述

    2022年1月28日
    67
  • 火眼金睛审核 一键轻松处理[通俗易懂]

    火眼金睛审核 一键轻松处理——学籍助手简介学籍助手是专为河北省义务教育学籍管理系统区县端开发的一款辅助工具(图)。该工具不影响原系统正常使用,只是扩充了一些实用功能,只是让学籍管理变得异常轻松简单(如您不是区县学籍管理员,请勿下载)。学籍助手具有严格的入库审核、强大的批量处理和轻松的数据对接功能,犹如为原学籍管理系统赋予一双慧眼、插上一对翅膀,从容处理繁杂的学籍变…

    2022年4月13日
    50
  • 阿里云服务器开放所有端口_服务器防火墙怎么设置

    阿里云服务器开放所有端口_服务器防火墙怎么设置进入阿里云服务器,点击防火墙添加规则添加防火墙规则:TCP+端口号在浏览器上输入:IP:8080如果能访问到tomcat页面,即为开放成功。

    2022年10月2日
    0
  • VS2010连接SQLite数据库[通俗易懂]

    VS2010连接SQLite数据库

    2022年2月21日
    57
  • C#UDP编程

    C#UDP编程一.UDP协议UDP(UserDatagramProtocol)协议就是“用户数据报协议”,它是一种无连接的协议,无连接主要是和TCP协议相比较的。我们知道当利用TCP协议传送数据的时候,首先必须建立连接(也就是所谓的握手)才可以传输数据。而当计算机利用UDP协议进行数据传输的时候,发送方只需要知道对方的IP地址和端口号就可以发送数据,而并不需要进行连接。由于UDP协议并不需要进行确定

    2022年9月8日
    2
  • MYSQL mediumText大字段存储错误问题排查「建议收藏」

    MYSQL mediumText大字段存储错误问题排查「建议收藏」思路:1:由于日志查询问题,没看到日志之前怀疑:MYSQL数据库字段长度是否真的足够,排查问题未果。2:步骤一未果,看日志了解错误信息如下Name”:”com.javartisan.audience_management.jsf_service.service.AudienceService”}org.springframework.orm.jpa.JpaSystemExcepti…

    2022年5月15日
    38

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号