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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • bootstrap fileinput 文件上传和回显「建议收藏」

    bootstrap fileinput 文件上传和回显「建议收藏」官网下载文件http://plugins.krajee.com/file-input/demobootstrapfileinput是基于bootstrap基础上的上传插件,so必要的bootstrap文件是要引用的…1.引用js和css文件fileinput.cssfileinput.min.js中文字体2.初始化fileinput前台jsp:<…

    2022年5月2日
    67
  • 编写程序计算1~10的平方和_用指针找出3个数的

    编写程序计算1~10的平方和_用指针找出3个数的给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c 。示例 1:输入:c = 5输出:true解释:1 * 1 + 2 * 2 = 5示例 2:输入:c = 3输出:false示例 3:输入:c = 4输出:true示例 4:输入:c = 2输出:true示例 5:输入:c = 1输出:true提示:0 <= c <= 231 – 1题解双指针,注意整形溢出class Solution {public

    2022年8月9日
    4
  • Servlet主要知识点

    Servlet主要知识点

    2021年10月3日
    35
  • Ubuntu安装Redis及使用「建议收藏」

    Ubuntu安装Redis及使用「建议收藏」NoSQL简介NoSQL,全名为NotOnlySQL,指的是非关系型的数据库随着访问量的上升,网站的数据库性能出现了问题,于是nosql被设计出来优点/缺点优点:高可扩展性分布式计算低成本架构的灵活性,半结构化数据没有复杂的关系缺点:没有标准化有限的查询功能(到目前为止)最终一致是不直观的程序分类类型部分代表特点列存储H…

    2022年9月14日
    0
  • 关于MSHTML_Html格式

    关于MSHTML_Html格式本文翻译自http://msdn.microsoft.com/workshop/browser/mshtml/overview/overview.aspMSDNHome>MSDNLibra

    2022年8月2日
    3
  • Java 工厂模式

    Java 工厂模式简单工厂模式详解简单工厂模式用来定义一个工厂类,它可以根据参数的不同返回不同类的实例,被创建的实例通常都具有共同的父类。因为在简单工厂模式中用于创建实例的方法是静态方法,因此简单工厂模式又被称为静态工厂方法模式,它属于类创建型模式。简单工厂模式的要点在于,当我们需要什么,只需要传入一个正确的参数,就可以获取我们所需要的对象,而无需知道其创建细节。简单工厂模式结构比较简单,其核心是工厂类的设计,其机构如图所示:在简单工厂模式结构图中包含如下几个角色。Factory(工厂角色):工厂角色即工厂类,它

    2022年7月20日
    17

发表回复

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

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