The full format of the try/except/else/finally statement in Python:
1 Try:2 Normal Block3 exceptA:4 Exception A Handle5 except:6 Other exception handle7 Else:8 Print "Else"9 finally:Ten Print("finally")1, normal condition (Try statement block execution no exception occurred): Execution order: statement block in 1.1 try, 1.2Else statement block, 1.3 finally statement block 2, exception (try statement execution exception): Execution order: 2.1 Executes a try statement, an exception occurs, interrupts the execution of a try statement block, 2.2 starts at the first except, if the corresponding Cxcepti is found On, the corresponding processing branch is entered and processed. If the individual except are not found, enter the default except branch. 2.3 Execute FINALLY statement block NOTE: Do not execute the ELSE statement block at this time 3.1 try must be executed, finally is to be executed 3.2 else and finally is optional, if else is selected, then must have except 3.3 have try, at least A except
Python try/except/else/finally Execution order