https://blog.csdn.net/weixin_42660771/article/details/80990665

错误(1):SyntaxError:'return' outside function

错误代码:

错误分析:语法错误,return放在了方法体外面

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

错误(2)TypeError:must be str,not int

错误代码:

错误分析:类型错误, 必须是一个字符串 不能是数字

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

错误(3)IndentationError: unindent does not match any outer indentation level

错误代码:

错误分析:Indent 是缩进错误:未知缩进不匹配任何缩进等级

解决办法:tab自动缩进

错误(4)SyntaxError: invalid syntax

错误代码:

错误分析:语法错误 , 非法的语法

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

错误(5) IndexError: string index out of range

错误代码:

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

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

错误(6)ValueError: substring not found

错误代码:

错误分析:子字符串未找到

解决办法:子字符串必须存在于上方字符串中

错误(7)IndexError: list index out of range

错误代码:

错误分析:索引错误:列表索引超出范围

解决办法:索引值必须在列表索引范围内

错误(8)AttributeError: 'tuple' object has no attribute 'remove'

错误代码:

错误分析:Attribute属性 object 对象   属性错误,元组对象没有属性‘remove’

解决办法:不对元组中元素进行‘remove’操作

错误(9)KeyError: 'fond'

错误代码:

错误分析:Key 键错误,字典里没有指定的键值’fond’
解决办法:要找字典内含有的key或value值

错误(10)TypeError: pop expected at least 1 arguments, got 0

错误代码:

错误分析:arguements 参数 expected期望 at least至少类型错误:pop方法希望得到至少一个参数,但是现在参数为0

解决办法:在dic1.pop()中输入dic1中有的非空参数

Python ——报错集锦的更多相关文章

  1. react+typescript报错集锦<持续更新>

    typescript报错集锦 错误:Import sources within a group must be alphabetized.tslint(ordered-imports) 原因:impo ...

  2. Python报错总结丶自定义报错

    Python报错总结: 常见异常 1,NameError: name 'a' is not defined:未定义函数名             2,IndentationError: uninden ...

  3. Python报错module 'scipy.misc' has no attribute 'xxx'

    Python报错module 'scipy.misc' has no attribute 'imresize' 解决办法: 安装Pillow包,命令如下: pip install Pillow 然后重 ...

  4. selenium python 报错“ unable to find binary in default location”

    selenium python 报错如下: raise exception_class(message, screen, stacktrace)selenium.common.exceptions.W ...

  5. 解决Python报错:local variable 'xxx' referenced before assignment(引)

    解决Python报错:local variable 'xxx' referenced before assignment(引) 解决Python报错:local variable 'xxx' refe ...

  6. python 报错 wxPyDeprecationWarning: Using deprecated class PySimpleApp.

    如题:python 报错 提示为 : wxPyDeprecationWarning: Using deprecated class PySimpleApp. 解决:将 wx.PySimpleApp() ...

  7. PyCharm 中文 字符 python 报错 的 完美 解决方案!

    PyCharm 中文 字符 python 报错 的 完美 解决方案! #_*_ coding:utf-8_*_ https://www.python.org/dev/peps/pep-0263/ 到p ...

  8. Python报错ModuleNotFoundError: No module named 'numpy'

    转载:https://blog.csdn.net/qq_39779233/article/details/103224712 Python报错ModuleNotFoundError: No modul ...

  9. python在linux的报错集锦

    1. 报错提示 /usr/lib/python2.7/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 ...

随机推荐

  1. [Swift]LeetCode820. 单词的压缩编码 | Short Encoding of Words

    Given a list of words, we may encode it by writing a reference string S and a list of indexes A. For ...

  2. Primitive Assembly

    I found something in the Specification of OpenGL Version 4.6 (Core Profile): The output of Vertex Sh ...

  3. grep的正则表达式结合的几个典型应用

    一 几个特殊的字符: ^ :只匹配行首  如^a 匹配以a开头的行abc,a2e,a12,aaa,...... example: grep "^a" //列出所有以a开头的行 $ ...

  4. 机器学习基石笔记:04 Feasibility of Learning

    原文地址:https://www.jianshu.com/p/f2f4d509060e 机器学习是设计算法\(A\),在假设集合\(H\)里,根据给定数据集\(D\),选出与实际模式\(f\)最为相近 ...

  5. vue-cli中webpack配置详解

    vue-cli是构建vue单页应用的脚手架,命令行输入vue init <template-name> <project-name>从而自动生成的项目模板,比较常用的模板有we ...

  6. python3安装sklearn机器学习库

    安装sklearn需要的库请全部在万能仓库下载: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy http://www.lfd.uci.edu/~go ...

  7. python 菱形继承问题究极版

    如果只是正常的菱形继承,经典类(python2中最后一个父类不继承object类)是深度优先,即会从左边父类开始一路走到底 新式类(最后一个父类继承了object类)是广度优先,即从左边父类开始继承, ...

  8. ios 自动化构建 code-select: error: tool 'xcodebuild' requires Xcode, but active developer directory.....

    问题描述: Pod installation complete! There are 2 dependencies from the Podfile and 3 total pods installe ...

  9. redis 系列13 集合对象

    一. 集合对象概述 这里的集合是string类型的无序集合,在集合对象中集合成员是唯一的,这就意味着集合中不能出现重复的数据.集合是通过哈希表实现的,集合中最大的成员数为 232-1 (4294967 ...

  10. Python和C++的混合编程(使用Boost编写Python的扩展包)

    想要享受更轻松愉悦的编程,脚本语言是首选.想要更敏捷高效,c++则高山仰止.所以我一直试图在各种通用或者专用的脚本语言中将c++的优势融入其中.原来贡献过一篇<c++和js的混合编程>也是 ...