大家好,又见面了,我是全栈君。
#try...except...
try:
You do your operations here;
......................
except ExceptionI:
If there is ExceptionI, then execute this block.
except ExceptionII:
If there is ExceptionII, then execute this block.
......................
else:
If there is no exception then execute this block.
#The except Clause with No Exceptions
try:
You do your operations here;
......................
except:
If there is any exception, then execute this block.
......................
else:
If there is no exception then execute this block.
#The except Clause with Multiple Exceptions
try:
You do your operations here;
......................
except(Exception1[, Exception2[,...ExceptionN]]]):
If there is any exception from the given exception list,
then execute this block.
......................
else:
If there is no exception then execute this block.
#The try-finally Clause
try:
You do your operations here;
......................
Due to any exception, this may be skipped.
finally:
This would always be executed.
......................
#Argument of an Exception
try:
You do your operations here;
......................
except ExceptionType, Argument:
You can print value of Argument here...
转载于:https://www.cnblogs.com/KennyRom/p/6294536.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/108689.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...