Python 中常见的错误类型

          1.类型错误

 
  
 TypeError: must be str, not int
 类型错误:必须是字符串,不能是数字.
 这种就是拼接的时候字符串和数字混用了,应该把一方转化为另一方
2.SyntaxError: invalid syntax语法错误:无效的语法
 解决办法就是看报错在哪一行,从这一行往上找错误

          3.IndentationError: unindent does not match any outer indentation level

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

    4.IndexError: string index out of range

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

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

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

    6.KeyError: 'fond'

    键值错误;没有指定的键值'fond'

    7.TypeError: pop expected at least 1 arguments, got 0

   类型错误:pop方法希望得到至少一个参数,但是现在参数为0

你可能感兴趣的:(Python 中常见的错误类型)