Exceptions in Python

Source: Internet
Author: User
Tags throw exception

Tag: RAC ble enters instance symbol ACE statement encounters param

The first is to define

Python uses an Exception object (Exception object) to represent an exception, and an exception is thrown when an error is encountered. If the exception object is not handled or captured, the program terminates execution with the so-called backtracking (Traceback, an error message).

And then the usual statements.

Try

  <statements> #运行try语句块 and try to catch the exception

Except <name1>: #如果name1异常发现, then execute the statement block.

  <statements>

Except (Name2, Name3): #如果元组内的任意异常发生, then capture it

  <statements>

Except <name4> as <variable>: #如果name4异常发生, then enter the statement block and name the exception instance variable

<statements>

exception: #任何异常都在这里抛出 span>

<statements>

else:

<statements> #如果没有异常发生, then execute the statement block

finally:

<statement> #无论是否有异常发生, the statement block is executed.

Again down is the manual throw exception

Raise statement

  typically used for custom exceptions and then manually throwing

The last sentence is to say that the exception is the son can not solve the problem of dad

Exceptions in 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.