码迷,mamicode.com
首页 > 编程语言 > 详细

Python2.7-内置异常类型

时间:2017-09-23 17:18:47      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:target   class   lan   ref   keyboard   war   div   nic   and   

python内置了许多异常类型,他们的继承关系如下:
-----------------------------------------------
BaseException +-- SystemExit +-- KeyboardInterrupt +-- GeneratorExit +-- Exception +-- StopIteration +-- StandardError | +-- BufferError | +-- ArithmeticError | | +-- FloatingPointError | | +-- OverflowError | | +-- ZeroDivisionError | +-- AssertionError | +-- AttributeError | +-- EnvironmentError | | +-- IOError | | +-- OSError | | +-- WindowsError (Windows) | | +-- VMSError (VMS) | +-- EOFError | +-- ImportError | +-- LookupError | | +-- IndexError | | +-- KeyError | +-- MemoryError | +-- NameError | | +-- UnboundLocalError | +-- ReferenceError | +-- RuntimeError | | +-- NotImplementedError | +-- SyntaxError | | +-- IndentationError | | +-- TabError | +-- SystemError | +-- TypeError | +-- ValueError | +-- UnicodeError | +-- UnicodeDecodeError | +-- UnicodeEncodeError | +-- UnicodeTranslateError +-- Warning +-- DeprecationWarning +-- PendingDeprecationWarning +-- RuntimeWarning +-- SyntaxWarning +-- UserWarning +-- FutureWarning +-- ImportWarning +-- UnicodeWarning +-- BytesWarning
-------------------------------------------------
一般在自己编写程序的时候需要注意的就是
TypeError、ValueError
在编写继承关系的类时,定义基类的需要被子类覆盖的方法时要注意NotImplementedError
-------------------------------------------------
原文链接:https://docs.python.org/2/library/exceptions.html

Python2.7-内置异常类型

标签:target   class   lan   ref   keyboard   war   div   nic   and   

原文地址:http://www.cnblogs.com/tccbj/p/7581433.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!