python常见错误总结
TypeError: 'module' object is not callable
模块未正确导入,层级关系没找对
缩进错误。
IndentationError: unindent does not match any outer indentation level
缩进错误。没有对齐
解决办法:
1.极有可能是空格和tab键混搭使用了,视图-显示符号-显示空格与制表符
引包错误
自己写的py文件不要与第三方库重名
编码错误
1、程序本身有编码,一般在程序的头部声明
2、使用的IDE有编码,除了python idle
3、读取外部数据or文件 decode(把其它编码的字符串转换成unicode编码) encode(把unicode编码转换成其它编码的字符串)
分析错误
看报错消息的首和尾
python常见错误总结的更多相关文章
- python 常见错误和异常 函数 正则表达式及多线程编程
生成随机密码#!/usr/bin/env python import stringfrom random import choice def gen_pass(num=9): all_chs = st ...
- python常见错误
最近刚刚接触Python,为了养成好习惯,遇到了诸多的问题,林林总总,在这里简单记录下: 编写简单的python语句时: module level import not at top of file ...
- Python常见错误:IndexError: list index out of range
用python写脚本查询字典时,在遍历字典时循环到某一项时老是报错 出现这种错误有两种情况: 第1种可能情况 list[index]index超出范围 第2种可能情况 list是空值就会出现 In ...
- 【python+selenium学习】Python常见错误之:IndentationError: unexpected indent
初入python+selenium学习之路,总会遇到这样那样的问题.IndentationError: unexpected indent,这个坑我已经踏进数次了,索性记录下来.都知道Python对代 ...
- SyntaxError :invalid syntax Python常见错误
1.忘记在 if , elif , else , for , while , class ,def 声明末尾添加 ":" 2.使用 = 而不是 ==,= 是赋值操作符而 == 是等 ...
- IndexError: list index out of range Python常见错误
引用超过list最大索引,此错误非常常见,注意列表的元素个数 ----------------------------------------------
- Python 常见错误
1. def func(): return a=3#错误的用法 2. class a: def func():#func至少要有一个self参数 ........................... ...
- Python 常见错误及解决办法
错误: Traceback (most recent call last): File "I:/Papers/consumer/codeandpaper/RegressionandGBDTa ...
- python常见错误和异常
1.BaseExeception 所有异常的基类 2.SystemEixt 解释器请求退出 3.KeyboardInterrupt 用户中断执行 4.Exception 常规错误的基类 5.StopI ...
随机推荐
- jquery 设置checked="checked"无效,radio未选中。。
jquery 设置checked="checked"无效,radio未选中.. 最好还是使用.prop(),在jQuery1.6版本之前.attr存在一些bug.在1.6之后它会自 ...
- android 开发 常用工具类
转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/38965311,本文出自[张鸿洋的博客] 打开大家手上的项目,基本都会有一大批的辅 ...
- 教你开启红米的USB大容量存储选项,全网首发哦
教你开启红米的USB大容量存储选项,全网首发哦 http://bbs.7to.cn/thread-10732-1-1.html 发表于 2014-4-29 110643 红米note入手也有两天了.各 ...
- redis订阅发布
一.简介 Pub/Sub 从字面上理解就是发布(Publish)与订阅(Subscribe),在Redis中,你可以设定对某一个key值进行消息发布及消息订阅,当一个key值上进行了消息发布后,所有订 ...
- 扩展Date的DateAdd方法--计算日期
Date.prototype.DateAdd = function(strInterval, Number) { var dtTmp = this; switch (strInterval) { ca ...
- 百度地图API首页 -- 鼠标经过:类似翻页效果和 类似锚点链接效果
var timer; $("li").on("mouseover",function(){ clearTimeout(timer); timer=null; $ ...
- nodeschool.io 7
~~ HTTP CLIENT ~~ Write a program that performs an HTTP GET request to a URL provided toyou as the f ...
- Hibernate4+Spring JPA+SpringMVC+Volecity搭建web应用(一)
pom.xml配置 <dependencies> <!-- hibernate begin --> <dependency> <groupId>org. ...
- org.springframework.web.servlet.PageNotFound No mapping found for HTTP request with URI [/AssetRepair/assetRepairController/test.do] in DispatcherServlet with name 'assetrepair'
web.xml文件配置: xxx-servlet.xml 我们可以发现DispatcherServlet会处理"jsp"后缀的请求;而模型视图后缀也是jsp的 如果这样配置会报以下 ...
- java作业——整数相加
设计思路:由于命令行参数都是字符串,所以解决问题的关键在于字符串和整数之间的转化.首先定义数组,让所要相加的数组成一个数组,然后实现数组的字符串转化为整数,最后相加输出就行了. 程序流程图: 源代码: ...