Python3 错误类型记录

论坛 期权论坛 脚本     
匿名技术用户   2020-12-29 11:05   11   0

1.SyntaxError : 'return' out side function

语法错误 : return 不能在方法以外使用

解决办法 : 将 return 放在方法体中使用

2.TypeError : must be str ,not int

类型错误 : 必须是str , 而不是int

解决办法 : 使用+拼接的时候,必须使用字符串或将数字转化为字符串

3.SyntaxError : invalid syntax

语法错误 : 非法的

解决办法 : 看报错信息在第几行,从这一行往上找错误

4.IndentationError : unident does not match any outer indentation level

缩进错误 : 未知缩进与任何缩进级别不匹配

解决办法 : Tab自动缩进

5.IndexError : string index out of range

索引错误 : 字符串索引超出了范围

解决办法 : 查看字符串的长度,索引要小于长度

6.IndexError : list index out of range

索引错误 : 列表索引超出了范围

解决办法 : 索引要小于长度

7.AttributeError : 'tuple' object has no attribute 'remove'

属性错误 : 元组对象没有属性'remove'

8.ValuError : subdtring not found

值错误 : 子字符串未找到

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP