python官方文档:https://docs.python.org/zh-cn/3/tutorial/index.html

1.indentationerror:unindent does not match any outer indentation level

原因:没有对齐导致的,设置notepad:视图--》显示符号--》显示空格和制表符

参考:https://www.crifan.com/python_syntax_error_indentationerror/comment-page-1/

2.indentationerror expected indented block

原因:没有对齐导致的

3.UnicodeDecodeError:'utf-8' codec can't decode byte xxx in position

一般这种情况出现得较多是在国标码(GBK)和utf8之间选择出现了问题,出现异常报错是由于设置了decode()方法的第二个参数errors为严格(strict)形式造成的,因为默认就是这个参数,将其更改为ignore等即可:

  line.decode('utf-8','ignore')

4.TypeError: write() argument must be str, not bytes

文件打开方式有问题,用open("testfile.txt", "wb+")

5.urllib have no urlopen

python 用的时urllib.request.urlopen,所以要import urllib.request

6.TypeError: cannot use a string pattern on a bytes-like object

需要使用html_url=html_url.decode('utf-8')#python3  ;参考:https://blog.csdn.net/lxh199603/article/details/53192883

7.UnicodeDecodeError: 'gbk' codec can't decode byte 0xa1 in position 58: illegal multibyte sequence

解决办法1:

FILE_OBJECT= open('order.log','r', encoding='UTF-8')

解决方法2:

       FILE_OBJECT= open('order.log','rb')

python 常见报错汇总的更多相关文章

  1. HDFS集群常见报错汇总

    HDFS集群常见报错汇总 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.DataXceiver error processing WRITE_BLOCK operation 报 ...

  2. Python 常见报错类型

    一.TypeError:类型错误,对象用来表示值的类型非预期类型时发生的错误 错误例子: age=18 print(‘我的年龄是’+age) 报错信息:TypeError: can only conc ...

  3. python常见报错信息!错误和异常!附带处理方法

    作为 Python 初学者,在刚学习 Python 编程时,经常会看到一些报错信息. Python 有两种错误很容易辨认:语法错误和异常. Python assert(断言)用于判断一个表达式,在表达 ...

  4. python常见报错类型

     更新ing 报错类型 报错内容 错误判断 错误解决方式 IndentationError IndentationError:unexpected indent 格式错误:以外缩进   Indenta ...

  5. MySQL常见报错汇总

    1>.ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it canno ...

  6. Python常见报错问题(不定时更新)

    1.TabError: inconsistent use of tabs and spaces in indentation 在缩进中不一致地使用tab键和空格键. 报错原因:混用了tab和space ...

  7. SpringBoot工程常见报错汇总

    1.Springboot测试类运行报错 java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you ...

  8. Python常见报错 - 使用openpyxl模块时出现错误: zipfile.BadZipFile: File is not a zip file

    背景 在pycharm项目下,有一个data.xlsx,主要用来存放接口测试用例数据的 要通过openpyxl库去读取data.xlsx,方法: openpyxl.load_workbook(path ...

  9. python常见报错

    1.Pycharm No module named requests 的解决方法 pip install requests 然后重启pycharm

随机推荐

  1. ML.NET 0.8特性简介

    本周.NET生态圈内的更新源源不断,除了.NET Core 2.2,ASP.NET Core 2.2和Entity Framework Core 2.2之外,ML.NET 0.8也一并登上舞台. 新的 ...

  2. RMQ算法详解

    RMQ算法,是一个快速求区间最值的离线算法,预处理时间复杂度O(n*log(n)),查询O(1),所以是一个很快速的算法. 当然这个问题用线段树同样能够解决,算法复杂度为:O(N)~O(logN) . ...

  3. HDU 5950 - Recursive sequence - [矩阵快速幂加速递推][2016ACM/ICPC亚洲区沈阳站 Problem C]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5950 Farmer John likes to play mathematics games with ...

  4. POJ 1816 - Wild Words - [字典树+DFS]

    题目链接: http://poj.org/problem?id=1816 http://bailian.openjudge.cn/practice/1816?lang=en_US Time Limit ...

  5. [tcpreplay] tcpreplay高级用法--使用tcpreplay-edit进行循环动态发包

    tcpreplay-edit提供了可对包进行修改的高级用法: --unique-ip Modify IP addresses each loop iteration to generate uniqu ...

  6. 玩具装箱&土地购买

    今天一天8h 写了两道斜率优化的题(别问我效率为什么这么低 代码bug太多了) 关键是思考的不周全 估计是写的题少手生 以后就会熟练起来了吧. 这道题显然有一个n^2的dp方程 设f[i]表示前i件物 ...

  7. linux测试环境搭建步骤

    一.建用户 1.新建用户root用户登录,执行命令:useradd + 用户名 -m -d + 指定路径如:新建用户liuwq ,指定路径/home/ios命令:useradd liuwq -m -d ...

  8. 继承数组的slice方法

    <script> var arr=[1,2,3,4,5]; console.log(Array.prototype.slice.call(arr,1)); </script> ...

  9. java Arrays工具

    package cn.sasa.demo4; import java.util.Arrays; public class ArrayDemo { public static void main(Str ...

  10. Xshell远程连接 与 Xftp文件传输

    刚开始接触Linux的时候,会想我该怎么在Windows连接到另一台Linux服务器,怎么把我Windows上的文件放到我Linux上面,网上搜索之后,知道可以用Xshell远程连接到Linux,用X ...