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