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. nodejs抓取页面内容,并分析有无某些内容的js文件

    nodejs获取网页内容绑定data事件,获取到的数据会分几次相应,如果想全局内容匹配,需要等待请求结束,在end结束事件里把累积起来的全局数据进行操作! 举个例子,比如要在页面中找有没有www.ba ...

  2. Understanding Flash: Blocks, Pages and Program / Erases

    https://flashdba.com/2014/06/20/understanding-flash-blocks-pages-and-program-erases/ In the last pos ...

  3. 存储json数据的编码问题

    在使用json.dumps时要注意一个问题   >>> import json >>> print json.dumps('中国') "\u4e2d\u5 ...

  4. Oracle 变量之 DDL_LOCK_TIMEOUT

    DDL_LOCK_TIMEOUTProperty DescriptionParameter type IntegerDefault value 0Modifiable ALTER SESSIONRan ...

  5. window.onresize监听事件

    window.onresize监听事件 onresize 事件会在窗口或框架被调整大小时发生. 支持onresize的标签:<a>, <address>, <b>, ...

  6. RabbitMQ 分布式设置和高可用性讨论

    abbitMQ的集群主要有配置方式,分别是:本地局域网Cluster,federation,shovel. RabbitMQ Cluster主要是用于同一个网段内的局域网. federation和sh ...

  7. [daily][nfs] nfs客户端设置

    [daily] 主机间目录共享 1. 安装nfs工具,其实是mount需要mount.fs 否则会出现类似如下错误: [root@stds ~]# mount -t nfs 192.168.7.1:/ ...

  8. Delphi2010分 AnsiChar(1个字节) 和WideChar(2个字节) 。D7都是AnsiChar。

    Delphi2010分 AnsiChar(1个字节) 和WideChar(2个字节) .D7都是AnsiChar.

  9. Altium Designer 绘图流程及快捷键

    1.Shift+Ctrl+g 设置栅格捕捉大小 2.Q 切换单位 3.E+N +点击字体 改变字体大小 4.自动布线前需在Mechanical 层和keepout层添加一个边框 5.打过孔实现双面走线 ...

  10. 使用axios加入进度条

    思路:(安慰剂按钮)首先当触发按钮时,设置拦截器,启动进度条从0开始到100满(html进度条用数值value来控制,默认为0),设置进度条的配置函数然后在后端返回函数中启动停止精度条的函数,为了保持 ...