Exception handling for Python

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.