Python day two-exception handling

Source: Internet
Author: User

Simply list the points of knowledge:

First, the basic wording

html = (). Decode (' Utf-8 ')
Except Exception as E:

Capturing multiple exceptions

Try: x= Int (Input ('input x:')) Y= Int (Input ('Input y:'))    Print('x/y =', x/y)exceptZerodivisionerror:#catch except 0 exceptions    Print("zerodivision")except(Typeerror,valueerror) as E:#catches multiple exceptions and outputs the exception object    Print(e)except:#catching the remaining type exceptions    Print("it ' s still wrong")
else: #没有异常时运行
Print ("No exeception")
Finally: #不管有没有异常都要运行
Print ("End")

Attention is except rather than catch, writing handy is easy to write catch

Python day two-exception handling

Related Article

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: 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.