2019-01-26
阅读量:
707
python中的内置异常有哪几类(2)
示例:
try:
a = 10/0
print a
except ArithmeticError:
print "This statement is raising an arithmetic exception."
else:
print "Success."
Output :
This statement is raising an arithmetic exception.
4. exception BufferError
当无法执行与缓冲区相关的操作时引发此异常。
5. exception LookupError
这是在映射或序列上使用的键或索引无效或未找到时引发的异常的基类。提出的例外是:
- KeyError异常
- IndexError
示例:
try:
a = [1, 2, 3]
print a[3]
except LookupError:
print "Index out of bound error."
else:
print "Success"






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论