1.SyntaxError 语法错误
这个错误很常见,没什么好说的,根据系统提示好好检查代码
2.类型错误,常见的是字符串和数字直接拼接在一起
name = '小刘'
age = 17
print(name + "今年"+ age)
TypeError: must be str, not int
字符串只能和字符串拼接
3.索引错误
list1=['a','b','c']
print(list1[5])
IndexError: list index out of range
要查找的索引值超出范围
4.缩进错误
IndentationError:unindent does not match any outer indentation level
缩进错误:未知缩进不匹配任何缩进等级
5.KeyError: 'fond'
错误为在字典查找没有的key值
6.ValueError: substring not found
值错误,没有找到输入的字符串,方法参数有问题
7.属性错误
AttributeError: 'tuple' object has no attribute 'remove'
说明该对象中没有这种属性