Python Errors and Exceptions

Source: Internet
Author: User
Tags finally block

1. try{}catch{} in Python

2. Raise exception

3. try...except. else.

4. Finally block

Exception handling in Python is not the same as in C #, and Python uses the Try,except key to handle exceptions, such as the following: keyword


2. Raise Excepption

Python assumes that it is necessary to throw exceptions again in except to use Keywordraise, similar to Throwkeyword in C #.

It is useful for code this must be executed if the TRY clause does isn't raise an exception

The else block is said to assume that the exception will be run if it is not thrown.

A finally Clauseis always executed before leaving Thetrystatement

Finally blocks are bound to be run, regardless of whether the exception is generated.

Specific page: http://www.verydemo.com/demo_c122_i12332.html

Python Errors and Exceptions

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