1.python中try/except/else/finally正常的語句是這樣的:
try:
normal excute block
except A:
Except A handle
except B:
Except B handle
except:
other exception handle
else:
if no exception,get here
finally:
print(hello world)
說明:
正常執行的程序在try下面執行normal excute block執行塊中執行,在執行中如果發生了異常,則中斷當前normal execute block 調到異常處理中開始執行,如果沒有異常則會執行else中的語句(前提是有else語句),finally語句是最后一步總會執行的語句。