python basis (15): Exception

        After python error is encountered, an exception is thrown. If the exception object has not been processed or captured, the program will use the so-called back (Traceback) to terminate execution. 

Handling exceptions:

  • Abnormality is an event occurs during program execution, will affect the normal operation of the program, it is generally needed to catch the exception and handle.
  • Abnormal capture using try / except / finally statements capture operation, and tell python how to do when an exception occurs.
try:
    print(aaa)
except:
else:
finally:

 

Guess you like

Origin blog.csdn.net/qq_26271435/article/details/90108758