Python
Basic
NameError
>>> print(a) Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> print(a) NameError: name 'a' is not defined
SyntaxError
#错误1 >>> a = 1 >>> if a: print(1) SyntaxError: expected an indented block IndentationError: excepted an indented block#错误2 >>> if a<b : SyntaxError: invalid character in identifier#错误3 >>> print('a) SyntaxError: EOL while scanning string literal
AttributeError
TypeError
IndexError
ValueError
KeyError
FileNotFoundError
Python 内置异常层次结构
Environment
Error: No module named XXX
Error: Empty suite
Error: io.UnsupportedOperation: not writable
Code
TypeError: only size-1 arrays can be converted to Python scalars
UnicodeEncodeError: 'gbk' codec can't encode character '\ufffd'
TypeError: list indices must be integers or slices, not tuple
Last updated