读文件时出现这个错误 'utf-8' codec can't decode byte 0xba in position 21: invalid start byte...
''' file2 文件内容:
很任性wheniwasyoung ''' 源代码:
f = open("file2",'r',encoding="utf-8")print(f.readline()) print(f.readline())print(f.readline())print(f.readline())print(f.readline())
错误提示:D:\python\python.exe D:/pythonWork/day2/file-op.pyTraceback (most recent call last): File "D:/pythonWork/day2/file-op.py", line 10, in <module> print(f.readline()) File "D:\python\lib\codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final)UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 21: invalid start byte 修改之后代码:f = open("file2",'r',encoding="gbk")
print(f.readline()) print(f.readline())print(f.readline())print(f.readline())print(f.readline())
执行结果:
很任性
Process finished with exit code 0
转载于:https://www.cnblogs.com/xuanmenghuan/p/11153875.html
读文件时出现这个错误 'utf-8' codec can't decode byte 0xba in position 21: invalid start byte...相关推荐
- pandas读文件UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8e in position 17: invalid start byte
@ 解决pandas读文件报错 UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8e in position 17: invalid sta ...
- Nmap中扫描时出现“utf8' codec can't decode byte 0xc0 in position 0: invalid start byte”错误的解决方案
关于Nmap中扫描时出现"utf8' codec can't decode byte 0xc0 in position 0: invalid start byte"错误的解决方案 ...
- UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0x80 in position 0: invalid start byte 错误解决
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte 错误解决 解决: ...
- Zenmap 报'utf8' codec can't decode byte 0xc0 in position 0: invalid start byte错误部分解决方案
错误样式:'utf8' codec can't decode byte 0xc0 in position 0: invalid start byte,如下图: 错误原因:报这个错误提示的意思我理解的是 ...
- P2转P3时出现‘utf-8‘ codec can‘t decode byte 0xb3 in position 0: invalid start byte(\x、decode解码)
直接上干货 实例: abc = b'\x85\xa6\xff\x01\x00\x00\x00\x01!\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ ...
- python错误:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 0: invalid start byte
python错误:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 0: invalid start byte解 ...
- python读取文件报错:‘utf-8‘ 或“gbk” codec can‘t decode byte 0xbe in position 627: invalid start byte
python读取文件时报错:'utf-8' 或"gbk" codec can't decode byte 0xbe in position 627: invalid start b ...
- python:读取文件内容解码 编码错误 UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xab in position 2: illegal
一.错误1(代码如下):UnicodeDecodeError: 'gbk' codec can't decode byte 0xab in position 2: illegal multibyte ...
- 调试错误:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
代码: #-*-coding:utf-8-*- import tensorflow as tf import numpy as np import matplotlib.pyplot as plt f ...
最新文章
- ansible笔记(11):初识ansible playbook(二)
- springboot+mybatis测试时遇到java.lang.NullPointerException
- 1028. List Sorting (25)
- linux ftp命令大全,linuxftp常用命令【图解】
- linux c fifo阻塞写和非阻塞写,linux—FIFO的使用与非阻塞标志(O_NONBLOCK)的影响
- AsnycTask的内部的实现机制
- 《机器学习Python实践》第7章——数据可视化
- jpype测试报错,找不到类raise _RUNTIMEEXCEPTION.PYEXC(Class %s not found % name)
- 关于nagios 邮件报警问题
- CF 705A Hulk
- SessionAffinity分发策略
- 移动体验大作战,冰桶算法全盘点
- 单片机延时C语言程序
- manjaro linux无线网卡,为 Manjaro 18.1.4 配置无线网卡
- itext7读取pdf 中文_pdf转为excel表
- 【密码资料】纳瓦霍密码
- c语言输出笑脸('\1')
- GCT考试通过后获得证书是双证还是单证?
- 数字人民币试点范围扩容;美国科技巨头市值蒸发超5万亿美元;蔡崇信再次出售阿里巴巴股票 | 每日大事件...
- java集合练习题十六个国家随机分为四组