关于python的 try 、except的执行情况:
try:
statement1
statement2
statement3
except Exception1:
#...
except Exception2:
#...
statement4
如果异常被捕获,statement4会被执行。
try:
statement1
statement2
statement3
except Exception1:
#...
except Exception2:
#...
except Exception3:
#...
finally:
statement4
statement5
如果异常未被捕获,statement5不会被执行
try:
statement1
statement2
statement3
except Exception1:
#...
except Exception2:
#...
except Exception3:
# ...
finall:
statement4
statement5
如果异常类型是Exception3,那么statement4和statement5 会被执行