【Python】Python读取文件报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0x99 in position 20: illegal multibyte sequence
环境描述
text.txt
今天的天气不错
是个皻的选择
读取文件的代码
#!/usr/bin/python
#-*- coding:UTF-8 -*-
f = open(r'D:\Python\Python_Demo\test.txt','r')
print(f.read())
f.close()
报错信息
解决办法
【Python】Python读取文件报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0x99 in position 20: illegal multibyte sequence的更多相关文章
- 【python】python读取文件报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 2: illegal multibyte sequence
python读取文件报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 2: illegal multibyte ...
- python 读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multibyte sequence
python读取文件时提示"UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal m ...
- python读取txt文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x8e in position 8: illegal multibyte sequence
python读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x8e in position 8: illegal multibyte ...
- 14 python读取文件时出现UnicodeDecodeError: 'gbk' codec can't decode byte 0xb7 in position 26: illegal multibyte sequence解决方法
>>> f = open("D:\\all.txt", "r")>>> f.read()Traceback (most re ...
- python3读文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x9f in position 2: illegal multibyte sequence
- python 读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multib
python 读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multib ...
- python UnicodeDecodeError: 'gbk' codec can't decode byte 0x99 in position 87: illegal multibyte sequence异常解决
我们处理文本文件时,经常会遇到这样的报错: UnicodeDecodeError: 'gbk' codec can't decode byte 0x99 in position 87: illegal ...
- python 读取文件时报错: UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 127: illegal multibyte sequence
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 127: illegal multibyte sequence p ...
- UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 16: illegal multibyte sequence
报错 UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 16: illegal multibyte sequence ...
随机推荐
- Centos7安装Beanstalkd
安装 //安装 yum -y install beanstalkd --enablerepo=epel //查看版本 beanstalkd -v //启动 -b断电重启会恢复 /usr/bin/bea ...
- Inversions After Shuffle CodeForces - 749E (概率,期望)
大意: 给定一个$n$排列, 随机选一个区间, 求将区间随机重排后整个序列的逆序对期望. 考虑对区间$[l,r]$重排后逆序对的变化, 显然只有区间[l,r]内部会发生改变 而长为$k$的随机排列期望 ...
- luogu P4548 [CTSC2006]歌唱王国
传送门 这题\(\mathrm{YMD}\)去年就讲了,然而我今年才做(捂脸) 考虑生成函数,设\(f_i\)表示最终串长为\(i\)的概率,其概率生成函数为\(F(x)=\sum f_ix^i\), ...
- 关于hstack和Svstack
关于hstack和Svstack import numpy as np>>> a = np.array((1,2,3))>>> aarray([1, 2, 3])& ...
- uni-app导航栏配置
uni-app写app的内容会与沉浸栏重合在一起,写好好多,都是有点问题的,这次终于找到解决的方法了,与大家分享一下 最简单的解决方式就是配置mainfest.json来关闭沉浸式.即通过打开应用的m ...
- PHP5 构造函数
在最近自己写的PHP小程序中遇到了如何使用PHP构造函数的情况,在PHP中允许我们在一个类中定义一个构造函数 如: <?php class User { public $name; functi ...
- Scrapy-redis分布式+Scrapy-redis实战
[学习目标] Scrapy-redis分布式的运行流程 Scheduler与Scrapy自带的Scheduler有什么区别 Duplication Filter作用 源码自带三种spider的使用 6 ...
- CentOS 7.4下源码编译安装配置LAMP环境详解
CentOS 7.4搭建LAMP,LAMP:Linux.Apache.MySQL.PHP. 目录:第一部分 准备工作第二部分 安装Apache服务第三部分 安装MySQL服务第四部分 搭建PHP运行环 ...
- Registry key 'Software\JavaSoft\Java Runtime Environment\CurrentVersion' has value '1.8', but '1.7'
第一种方法:安装1.8之前安装了1.7,将1.7卸载就好了. 第二种方法:删掉Windows\System32下的java.exe, javaw.exe 就行了,但是安装的1.8的jdk会回到1.7的 ...
- VUE+DJANGO
1.router类型不能设置为history const router = new Router({ mode: '', routes, }); //避免打包到django后刷新报错 2.样式放sta ...