1 #basic logic blocks for exception handling2 #is as follows:3 #Exception refers to all errors that can catch all errors4 #valueerror Indexerror ... It's a subclass of exception.5 #www.cnblogs.com/wupeiqi/articles/5017742.html sums up a number of sub-categories of error types6 #Why do you want to output subclass exceptions? Might be the reason for the log to quickly locate the problem7 #try else no exception occurs to execute code after else8 #finally: Regardless of whether an exception occurs, the following code will be executed finally9 whileTrue:Ten Try: Onem = input ("Please enter the content:") AI=Int (m) - #The code above executes the following code if there is no error - exceptIndexerror as E: the Print("Input Error") - exceptValueError as E: - Print("ValueError") - exceptException as E: + Print("Exception", E) - Else: + A Print("Else") at finally: - Print("...")
Exception handling for Python