python编程中常见报错总结:,python编程中常见报
分享于 点击 32929 次 点评:55
python编程中常见报错总结:,python编程中常见报
1.TypeError:must be str,not int
类型错误:必须是一个字符串,不是数字
解决办法:使用+拼接时必须使用字符串,或将数字转化成字符串
2.SyntaxErrou:invalid syntax
语法错误 :非法的语法
解决办法:看报错信息在第几行,从这一行往上找错误
3.IndentationError: unindent does not match any outer indentation level
indent 缩进错误 : 未知缩进不匹配任何缩进等级
解决办法:tab自动缩进
4.IndexError: string index out of range
索引错误:字符串超出了范围
解决办法:查看字符串的长度 索引要小于长度
5.ValueError: substring not found
值错误:子字符串未找到
6.IndexError: list index out of range
索引错误:列表索引超出范围
7.AttributeError: 'tuple' object has no attribute 'remove'
属性错误:元组对象没有属性'remove'
8.KeyError: 'fond'
key 键错误:没有指定的键值“fond”
9.TypeError: pop expected at least 1 arguments, got 0
类型错误:pop方法希望得到至少一个参数,但是现在参数为0
10.SyntaxError: Non-UTF-8 code starting with '\xe7'
语法错误:Non-UTF-8 代码不行
解决方法:在第一行写:coding:utf-8 ,然后注释掉
相关文章
- 暂无相关文章
用户点评