Python----Object-oriented---exception handling

Source: Internet
Author: User

First, what is an exception

An exception is a signal that an error occurs, and once the program fails, and the program does not handle the error, an exception is thrown and the program's operation terminates.

For example:

1 Print('1')2 Print('2')3 Print('3')4int'AAAA')5 Print('4')6 Print('5')7 Print('6')8 9 The result is:Ten  One Traceback (most recent): A1 -2 -File"C:/users/xu516/pycharmprojects/python Full Stack development/third module/object-oriented Programming/32 exception handling. PY", line 6,inch<module> the3 -int'AAAA') -Valueerror:invalid literal forInt () with base 10:'AAAA'

The following code is not executed after the error

Second, there are two types of errors

1. Syntax error

For example:

1 Print (XXX  2  3if 1 > 3 4  5 Result:  6  7   "c:/users/xu516/pycharmprojects/python full Stack development/third module/object-oriented Programming/32 exception handling. PY", line 8      9     ^ten while parsing

2. Logic Error

Python----Object-oriented---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: 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.