Common exceptions in ptyhon

Exception base class for all exceptions

AttributeError raised when attribute application or assignment fails

IOError is raised when trying to open a file that does not exist

IndexError is raised when using an index that does not exist in the sequence

KeyError is raised when using a key that does not exist in the map

NameError is raised when the name (variable) cannot be found

SyntaxError is raised when the code is in the wrong form

TypeError is raised when a built-in operation or function is applied to an object of the wrong type

ValueError is raised when a built-in operation or function is applied to an object of the correct type, but the object uses an inappropriate value

ZeroDivisionError is raised when the second parameter of a division or division operation is 0

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325017475&siteId=291194637