IndentationError: unexpected indent:缩进问题
按python规则缩进
AttributeError: ‘tuple’ object has no attribute ‘append’:属性错误
元组没有append方法,换列表即可
TypeError: can only concatenate str (not “int”) to str:类型错误
提示必须是字符串,不能是数字,需要类型转化
NameError: name ‘顺利结束’ is not defined :访问的变量名不存在
如果是变量先定义变量,如果输出文字,需打上引号
IndexError: list index out of range:索引错误,大概率是超出了
下图中索引 0-4
KeyError: ‘c’:在读取字典中的key和value时,key不存在
修改字典或者修改key
SyntaxError: invalid syntax:语法错误
使用中文,少了冒号:等等都会提示这个错误
python 常规报错总结
最新推荐文章于 2023-09-16 14:50:37 发布