- 论坛徽章:
- 0
|
Python Manual里对try catch 语句执行的解释
The try statement works as follows.
First, the try clause (the statement(s) between the try and except keywords) is executed.
If no exception occurs, the except clause is skipped and execution of the try statement is finished.
If an exception occurs during execution of the try clause, the rest of the clause is skipped. Then if its type matches the exception named after the except keyword, the except clause is executed, and then execution continues after the try statement.
If an exception occurs which does not match the exception named in the except clause, it is passed on to outer try statements; if no handler is found, it is an unhandled exception and execution stops with a message as shown above.
都输出B,我想是因为isinstance(C(),B)和isinstance(D(),B)都是True,所以第一个catch满足了就不再继续catch了。
[ 本帖最后由 wolfg 于 2006-3-15 17:00 编辑 ] |
|