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

  

Python handling an exception的更多相关文章

  1. Error Handling and Exception

    The default error handling in PHP is very simple.An error message with filename, line number and a m ...

  2. Python中异常(Exception)的总结

    Python中的异常处理 异常处理的语句结构 try: <statements> #运行try语句块,并试图捕获异常 except <name1>: <statement ...

  3. Python 异常(Exception)

    1. 字符串为构造函数的参数 >> raise Exception('hyperdirve overload') Exception Traceback (most recent call ...

  4. python内建Exception类型

    1.Exception类型及分层结构如下: BaseException +-- SystemExit +-- KeyboardInterrupt +-- GeneratorExit +-- Excep ...

  5. Python之异常处理-Exception

    在写python程序时, 不要害怕报错, 也不要怕自己的英语不够好, 不要看到一有红色的字就心里发怂. 其实报的错也是有套路可寻滴~识别了异常的种类, 才能对症下药. 常见异常: Exception ...

  6. TIJ——Chapter Twelve:Error Handling with Exception

    Exception guidelines Use exceptions to: Handle problems at the appropriate level.(Avoid catching exc ...

  7. 在eclipse中用java调用python报错 Exception in thread "main" ImportError: Cannot import site module and its dependencies

    最近做项目需要用java调用python,配置了jython后,运行了例子代码: 获得一个元组里面的元素: import org.python.util.PythonInterpreter; publ ...

  8. Python 2.7 Exception格式化工具

    首先说一个发现: try: 抛错误,抛异常 except Exception as e: 都被这里抓住了 except Error as e: 这里啥事都没了 然后,说说Exception as e的 ...

  9. python之最强王者(11)——异常(exception)

    1.Python 异常处理 python提供了两个非常重要的功能来处理python程序在运行中出现的异常和错误.你可以使用该功能来调试python程序. 异常处理: 本站Python教程会具体介绍. ...

随机推荐

  1. HDU 3378

    http://acm.hdu.edu.cn/showproblem.php?pid=3378 规则去玩三国杀就理解了 纯模拟 注意的点:有已经分出胜负但还在杀的情况出现,所以要每次杀操作前判断是否分出 ...

  2. 上周面试回来后写的Java面试总结,想进BAT必看

    上周陪同之前一起工作的同事去面试(乔治,小袁,鹏飞(面试人)),第一站是去深圳,第二站上海,第三站杭州.面试什么公司我在这里就不多说了,你们知道是一线公司就行.其实本来真的没打算写这篇文章,主要是自己 ...

  3. Mac 配置前端基本环境

    一,sublime 下载一个版本,替换packages,要想shift  command p管用,得在sublime里面control -,然后把 import urllib.request,os,h ...

  4. caffe学习笔记教程

    1 官网:http://caffe.berkeleyvision.org/ 2 豆丁网中:http://www.docin.com/p-871820917.html 3 下载的caffe中,.../d ...

  5. Notes on UE4-Blender workflow

    In UE4: When you import a rigged model (mesh parents armature) to UE4, it will be converted to a Ske ...

  6. double类型与Double包装类型

    先看下面的代码 package test; public class DoubleTest { public static void main(String[] args) { Double oD = ...

  7. 模块(Modules)

    一.引入模块 模块:当编写更大的应用程序时,所有的代码肯定会分成多个文件,这样便于维护,另外已经编写好的函数和对象在被多个程序中使用时,不用把函数和对象拷贝到每个程序中. 模块支持以上功能,在Pyth ...

  8. C/C++比较容易搞混的一些写法

    #include <stdio.h> int main() { int a = 101; char ch = *(char *)&a; //*(char *)&a:含义就是 ...

  9. ajax完成团队信息异步添加【实际项目】

    第一:ajax往后台传参如何串(目前理解是json数组直接传给对象) 第二:ajax返回的数值通过PrintWriter.print方法返回 [参考前台页面关于团队信息是如何实现的] 参考页面user ...

  10. THREE.OrbitControls参数控制

    // Set to false to disable this control//鼠标控制是否可用 this.enabled = true; // "target" sets th ...