#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. python2 之 pyh2

    1.功能 pyh作爲基於python的簡易html生成庫,收到了廣大python愛好者(比如說我,當然其他人沒有調查過)的深切喜愛. 簡潔的行文風格繼承了python一貫的作風,可以讓你用簡單的Pyt ...

  2. Percona 工具 pt-query-digest的使用

    pt-query-digest说明 pt-query-digest 用来格式化分析MySQL产生的日志,如:慢查询日志.二进制日志.通用日志,根据不同的条件进行分析并生成报告. pt-query-di ...

  3. Yahoo关于性能优化的N条规则

    本来这是个老生常谈的问题,上周自成又分享了一些性能优化的建议,我这里再做一个全面的Tips整理,谨作为查阅型的文档,不妥之处,还请指正: 一. Yahoo的规则条例: 谨记:80%-90%的终端响应时 ...

  4. (IOCP)-C#高性能Socket服务器的实现

    C#高性能Socket服务器的实现(IOCP) https://www.jianshu.com/p/c65c0eb59f22 引言 我一直在探寻一个高性能的Socket客户端代码.以前,我使用Sock ...

  5. Python中super()和__init__()方法

    采用新式类,要求最顶层的父类一定要继承于object,这样就可以利用super()函数来调用父类的init()等函数, 每个父类都执行且执行一次,并不会出现重复调用的情况.而且在子类的实现中,不用到处 ...

  6. lapis 处理接收到的json 数据

     备注:      在restful api 开发过程中,大家一般使用的都是json 格式的数据lapis       在处理json 数据上也是比较方便的   1. 使用的api 说明 local ...

  7. Navicat Premium 连接O​r​a​c​l​e​ ​出现o​r​a​-​1​2​5​0​5​ ​错​误​解​决​方​案

    找到listener.ora文件:我的Oracle是安装在F盘, 路径为:F:\oracle\product\10.2.0\db_1\network\admin\listener.ora  改动前的配 ...

  8. 完美版js金钱正则表达式校验

    <!doctype html> <html lang="en">  <head>   <meta charset="UTF-8& ...

  9. Windows 键盘快捷键概述

    在 Windows 中工作时,利用快捷键代替鼠标.可以利用键盘快捷键打开.关闭和导航“开始”菜单.桌面.菜单.对话框以及网页.键盘还可以让您更简单地与计算机交互.  单击一个标题或按 TAB 键可以突 ...

  10. 系统管理员都要知道的 30 个 Linux 系统监控工具

    1. top - 进程活动监控命令 top 命令会显示 Linux 的进程.它提供了一个运行中系统的实时动态视图,即实际的进程活动.默认情况下,它显示在服务器上运行的 CPU 占用率最高的任务,并且每 ...