先补充些iter函数的用法:iter()其实就是一个迭代器,参数可传个list、dict等等,然后可通过调用next函数获取下一个元素,默认并未指向对象的第一个元素,可理解为指向了第一个元素的前面的位置。

第8课:异常处理

1、异常处理可以提高程序的容错性

re = iter(range(4))
for i in range(100):
print re.next()
print 'hello'

循环到第6次,由于re.next()没有元素返回了,会有StopIteration的异常。整个程序将会中断。写程序时,如果知道可能犯错的地方或犯错的类型,可以针对异常类型定义好'应急方案'

re = iter(range(5))
try:
for i in range(100):
print re.next()
print 'hello'
except StopIteration:
print 'here is end',i

将try中容易出错的部分,后面跟上except,来说明如果try中发生StopIteration时,程序该做的事情,如果没有发生异常,except部分将被跳过。

2、异常处理的完成语法结构:

try:

except exception1:

except exception2:
except:
......
else: finally:

如果try中有异常发生,将执行except。异常层层比较,看是否是exception1, exception2...,直到找到其归属,执行相应的except中的语句。如果except后面没有任何参数,那么表示所有的exception都交给这段程序处理。比如:

try:
print(a*2)
except TypeError:
print("TypeError")
except:
print("Not Type Error & Error noted")

由于a没有定义,所以是NameError。异常最终被except:部分的程序捕捉。???

3、如果无法将异常交给合适的对象,异常将继续向上层抛出,直到被捕捉或者造成主程序报错。比如下面的程序

def test_func():
try:
m = 1/0
except NameError:
print("Catch NameError in the sub-function") try:
test_func()
except ZeroDivisionError:
print("Catch error in the main program")

子程序的try...except...结构无法处理相应的除以0的错误,所以错误被抛给上层的主程序。

如果try中没有异常,那么except部分将跳过,执行else中的语句。

finally是无论是否有异常,最后都要做的一些事情。

流程如下,

try->异常->except->finally

try->无异常->else->finally

4、抛出异常raise:其实就是自己写个异常

我们也可以自己写一个抛出异常的例子:

StopIteration是一个类。抛出异常时,会自动有一个中间环节,就是生成StopIteration的一个对象。Python实际上抛出的,是这个对象。当然,也可以自行生成对象:

raise StopIteration()

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhAAAAE2CAMAAAAHw1sNAAAAAXNSR0IArs4c6QAAAWtQTFRFJigiUJnT2ZlK+blwdCgi+SZyJihw+f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0mH5Xrh1TH97Ozt6TfRK8mIWl37o3GV5TlKIwoSeKbzub9G269ke7dUk06boO8AlJ9F3X9UChdUK0Rp7gXkvq030iMqFnOBSiRSumA6tfTfcZtAk9wJAAI6YAAIBCAAAAhQAAAAoBAECw8M6fEpJC1F3WowwRdORDk9Hbg7lAkJc5ZiKRUKeraDKcf7iWEDsr91ohXFC6cT1gFUi0T4hBXWTQA+WLPlSIfiLEsC1DergfmkJU5mulG8nkdb5JtpLXRogHkUwuaUefZF0J0UI2nljaNt1HEUIMYBRZUOTEH0EI/qY0M8onTZjXRjw/Tst4uR+aQlTml5drRob8J5vU8gvX2NrCy0vqaGX+OuOIfe1z/9l4ZJmcdqMm5Yin3TZByIUQasrO8C1lHqZCMC3YIVSozFMlsBFCHnVTCL/ZeFSZNu1GNhnscVdjtz0Joa4d3GQHrRMieIVgZqY0IO2DkmGTEPKoa5PhLxuPKtPnPUhC8MGzxMbaxB8XQmjXRjwdSp8rRK0hIWrNCOEjG48+60tNu5GEkNbWJv64EEK7dugIQdMjhDS9U5icNxmdEKJBNh5VZp12k1ABBTOxNvFHEoJfwTkT94hAhrrJ6I5CMPt3SgjnVBeZ/UKWadNuFCEIBUbVpI182koIPuuD+hDyWjiVXVaIzPJ1oykhyOfPhvGrOyHcp7qY+XFUmZp2o0/KiZnRpJr4I1WAlV39YyqrXztsYWe4UYYZTFoJwfomLIQwdpK8w8KFEO5TXWQGLa1MTLsxDG1Sjlw/QJv4U5CuBjlJ64dIjxnIj9N9HyJouGW2CTKPzpB1XQfw5E/0iBBumW26kUcH+XGiohBumW26kUdnqF5/h6gQAABAIQAAGBz8PwMoR1JD1qjlAAAAAElFTkSuQmCC" alt="" />

其中上图中想要打印出异常信息‘参数为空’  直接print e即可。

Python基础学习(第8天)的更多相关文章

  1. Day1 Python基础学习

    一.编程语言分类 1.简介 机器语言:站在计算机的角度,说计算机能听懂的语言,那就是直接用二进制编程,直接操作硬件 汇编语言:站在计算机的角度,简写的英文标识符取代二进制去编写程序,本质仍然是直接操作 ...

  2. 0003.5-20180422-自动化第四章-python基础学习笔记--脚本

    0003.5-20180422-自动化第四章-python基础学习笔记--脚本 1-shopping """ v = [ {"name": " ...

  3. Day1 Python基础学习——概述、基本数据类型、流程控制

    一.Python基础学习 一.编程语言分类 1.简介 机器语言:站在计算机的角度,说计算机能听懂的语言,那就是直接用二进制编程,直接操作硬件 汇编语言:站在计算机的角度,简写的英文标识符取代二进制去编 ...

  4. Python 基础学习 总结篇

    Python 基础学习总结 先附上所有的章节: Python学习(一)安装.环境配置及IDE推荐 Python学习(二)Python 简介 Python学习(三)流程控制 Python学习(四)数据结 ...

  5. (一)python基础学习

    根据廖雪峰老师的python教程写一些学习总结! Python基础学习 1.使用list和tuple (1)list Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时 ...

  6. python基础学习(起步)

    目录 python基础学习(起步) 变量 常量 变量的内存管理 python垃圾回收机制 变量的其他赋值方式 今日编程小题 本人能力有限,若有偏颇之处请读者大大不吝赐教! 祝大家每天都在成长! pyt ...

  7. Python基础学习二

    Python基础学习二 1.编码 utf-8编码:自动将英文保存为1个字符,中文3个字符.ASCll编码被囊括在内. unicode:将所有字符保存为2给字符,容纳了世界上所有的编码. 2.字符串内置 ...

  8. Python基础学习一

    Python基础学习一 1.变量与常量 变量名:大小写英文.数字.下划线的组合,数字不能开头 常量名:习惯上常量用大写字母命名,例如"PI" 2.多行输出 转义符:反斜杠(),如果 ...

  9. Python基础学习五

    Python基础学习五 迭代 for x in 变量: 其中变量可以是字符串.列表.字典.集合. 当迭代字典时,通过字典的内置函数value()可以迭代出值:通过字典的内置函数items()可以迭代出 ...

  10. Python基础学习四

    Python基础学习四 1.内置函数 help()函数:用于查看内置函数的用途. help(abs) isinstance()函数:用于判断变量类型. isinstance(x,(int,float) ...

随机推荐

  1. CG group

    Linux CGroup全称Linux Control Group, 是Linux内核的一个功能,用来限制,控制与分离一个进程组群的资源(如CPU.内存.磁盘输入输出等).这个项目最早是由Google ...

  2. GTID的主从复制的配置

    主库配置: (一).修改配置文件:在my.cnf配置文件中开启如下选项. [mysqld] #GTID: gtid_mode=on enforce_gtid_consistency=on server ...

  3. curl: (60) SSL certificate problem: unable to get local issuer certificate

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html 内部邀请码:C8E245J (不写邀请码,没有现金送) 国 ...

  4. nfs服务、crond服务

    一.nfs服务 NFS 是Network File System的缩写,即网络文件系统.一种使用于分散式文件系统的协定,由Sun公司开发,于1984年向外公布.功能是通过网络让不同的机器.不同的操作系 ...

  5. CNN学习笔记:梯度下降法

    CNN学习笔记:梯度下降法 梯度下降法 梯度下降法用于找到使损失函数尽可能小的w和b,如下图所示,J(w,b)损失函数是一个在水平轴w和b上面的曲面,曲面的高度表示了损失函数在某一个点的值

  6. mfc学习---文档视图架构

    MFC的AppWizard可以生成三种类型的应用程序:基于对话框的应用.单文档应用(SDI)和多文档应用(MDI).   一般情况下,采用文档/视结构的应用程序至少应由以下对象组成:       1. ...

  7. websocket redis实现集群即时消息聊天

    websocket与redismq实现集群消息聊天 1.application.properties server.port=8081 #thymeleaf配置 #是否启用模板缓存. spring.t ...

  8. ubuntu中在Launcher上添加Android Studio的运行图标

    运行命令创建desktop文件: sudo gedit /usr/share/applications/android_studio.desktop 打开窗口后输入以下内容,注意Exec和Icon要修 ...

  9. Windows 下c获取文件目录

    由于要插数据库,构建sql语句,需要文件名,在网上找了半天,无奈都是Linux下的专用函数,伤心,,还有那个下载URL ,还木搞好,就要走啦,心焦哇 #include<iostream> ...

  10. QT中没有byte

    QT里没有没有byte数据类型的 自己定义:#define byte unsigned char