Open
Description
http://www.pythondoc.com/pythontutorial3/classes.html#tut-exceptionclasses
发生的异常其类型如果是 except 子句中列出的类,或者是其派生类,那么它们就是相符的(反过来说--发生的异常其类型如果是异常子句中列出的类的基类,它们就不相符)。例如,以下代码会按顺序打印 B,C,D:
英文原文:
A class in an except clause is compatible with an exception if it is the same class or a base class thereof (but not the other way around — an except clause listing a derived class is not compatible with a base class). For example, the following code will print B, C, D in that order:
应该基类 / 派生类互换位置,修改为
如果该异常是同样的类, 或是它的基类,那么异常类可以与该异常类相容, (相反 ,—— 一个 except 语句列出的派生类与其基类并不相容)比如就像下面代码一样,会依次打印出 B, C, D:
Metadata
Metadata
Assignees
Labels
No labels