[关闭]
@songying 2018-07-25T18:15:17.000000Z 字数 1355 阅读 1209

常见异常

python高级特性


  1. BaseException
  2. +-- SystemExit
  3. +-- KeyboardInterrupt
  4. +-- GeneratorExit
  5. +-- Exception
  6. +-- StopIteration
  7. +-- StandardError
  8. | +-- BufferError
  9. | +-- ArithmeticError
  10. | | +-- FloatingPointError
  11. | | +-- OverflowError
  12. | | +-- ZeroDivisionError
  13. | +-- AssertionError
  14. | +-- AttributeError
  15. | +-- EnvironmentError
  16. | | +-- IOError
  17. | | +-- OSError
  18. | | +-- WindowsError (Windows)
  19. | | +-- VMSError (VMS)
  20. | +-- EOFError
  21. | +-- ImportError
  22. | +-- LookupError
  23. | | +-- IndexError
  24. | | +-- KeyError
  25. | +-- MemoryError
  26. | +-- NameError
  27. | | +-- UnboundLocalError
  28. | +-- ReferenceError
  29. | +-- RuntimeError
  30. | | +-- NotImplementedError
  31. | +-- SyntaxError
  32. | | +-- IndentationError
  33. | | +-- TabError
  34. | +-- SystemError
  35. | +-- TypeError
  36. | +-- ValueError
  37. | +-- UnicodeError
  38. | +-- UnicodeDecodeError
  39. | +-- UnicodeEncodeError
  40. | +-- UnicodeTranslateError
  41. +-- Warning
  42. +-- DeprecationWarning
  43. +-- PendingDeprecationWarning
  44. +-- RuntimeWarning
  45. +-- SyntaxWarning
  46. +-- UserWarning
  47. +-- FutureWarning
  48. +-- ImportWarning
  49. +-- UnicodeWarning
  50. +-- BytesWarning

Exception

StandardError

ImportError:

当使用 import 语句或 from ... import失败时引发的异常

ValueError

Raised when a built-in operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as IndexError.

AssertionError

当一条assert语句失败时触发。

RuntimeError

Raised when an error is detected that doesn’t fall in any of the other categories. The associated value is a string indicating what precisely went wrong.

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注