UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 9: illegal multibyte sequence

时间:2022-12-13 07:53:01

最近对爬虫有点着迷,

在用bs4模块时,遇到报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 9: illegal multibyte sequence

bs4获取本地文件内容

from bs4 import BeautifulSoup
soup = BeautifulSoup(open('a.html'), 'html.parser')
print(soup.prettify()) # 打印本地文件的内容
其中,a.html的内容为:
<div>大家好</div>
<p>你好啊</p>

运行报错

UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 9: illegal multibyte sequence

上面是字符流的问题

from bs4 import BeautifulSoup
soup = BeautifulSoup(open('a.html', 'rb'), 'html.parser')
print(soup.prettify()) # 打印本地文件的内容

运行结果:

UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 9: illegal multibyte sequence

 

UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 9: illegal multibyte sequence的更多相关文章

  1. UnicodeDecodeError&colon; &&num;39&semi;gbk&&num;39&semi; codec can&&num;39&semi;t decode byte 0xae in position 199&colon; illegal multibyte sequence

    =================================版权声明================================= 版权声明:原创文章 谢绝转载  请通过右侧公告中的“联系邮 ...

  2. UnicodeDecodeError&colon; &&num;39&semi;gbk&&num;39&semi; codec can&&num;39&semi;t decode byte 0xae in position 120&colon; illegal multibyte sequence

    UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 120: illegal multibyte sequence f ...

  3. UnicodeDecodeError&colon; &&num;39&semi;gbk&&num;39&semi; codec can&&num;39&semi;t decode byte 0xae in position 167&colon; illegal multibyte sequence

    UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 167: illegal multibyte sequence文件 ...

  4. UnicodeDecodeError&colon; &&num;39&semi;gbk&&num;39&semi; codec can&&num;39&semi;t decode byte 0xae in position 357&colon; illegal multibyte sequence 错误解决方法(已解决)

    今天在搭建数据驱动测试框架的时候遇到这个错误: 好在我英语水平还不错(也就六级水平吧),根据英文提示说是多字节数据顺序是非法的 顺着错误往上找发现 File "C:\Users\Mr雷的电脑 ...

  5. python 读取文件时报错UnicodeDecodeError&colon; &&num;39&semi;gbk&&num;39&semi; codec can&&num;39&semi;t decode byte 0x80 in position 205&colon; illegal multibyte sequence

    python读取文件时提示"UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal m ...

  6. 14 python读取文件时出现UnicodeDecodeError&colon; &&num;39&semi;gbk&&num;39&semi; codec can&&num;39&semi;t decode byte 0xb7 in position 26&colon; illegal multibyte sequence解决方法

    >>> f = open("D:\\all.txt", "r")>>> f.read()Traceback (most re ...

  7. python3安装xadmin出现 UnicodeDecodeError&colon; &&num;39&semi;gbk&&num;39&semi; codec can&&num;39&semi;t decode byte 0xa4 in position 3444&colon; illegal multibyte sequence

    python3的环境安装xadmin时,直接pip install xadmin出现 Downloading xadmin-0.6.1.tar.gz (1.0MB) 100% |███████████ ...

  8. 【python】python读取文件报错UnicodeDecodeError&colon; &&num;39&semi;gbk&&num;39&semi; codec can&&num;39&semi;t decode byte 0xac in position 2&colon; illegal multibyte sequence

    python读取文件报错UnicodeDecodeError: 'gbk' codec can't decode byte 0xac in position 2: illegal multibyte ...

  9. python 读取文件时报错: UnicodeDecodeError&colon; &&num;39&semi;gbk&&num;39&semi; codec can&&num;39&semi;t decode byte 0xa4 in position 127&colon; illegal multibyte sequence

    UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 127: illegal multibyte sequence p ...

随机推荐

  1. Thrift:Quick Start

    Thrift 快速开始 1 Thrift 介绍 目前流行的服务调用方式有很多种,例如基于 SOAP 消息格式的 Web Service,基于 JSON 消息格式的 RESTful 服务等.其中所用到的 ...

  2. Unity3D Sprite Draw Call合批规则

    只要材质相同,并Sprite在同一Atlas里,就可以合批. 不论Sorting Layer不同,还是Sorting Order不同. 材质相同的两个不同Sorting Order之间插入一个不同材质 ...

  3. (引用)web安全测试

    转载:http://www.51testing.com/html/44/15020244-908645.html Web安全测试之XSS XSS 全称(Cross Site Scripting) 跨站 ...

  4. box-shadow使用指南

    Summary The box-shadow property describes one or more shadow effects as a comma-separated list. It e ...

  5. php中soap应用

    原文:php中soap应用 SOAP:简单对象访问协议 (SOAP:Simple Object Access Protocol) 简单对象访问协议(SOAP)是一种轻量的.简单的.基于 XML 的协议 ...

  6. Eclipse常见操作

    Eclipse打开Package Explorer Window > Show View > Other Java > Package Explorer 然后可以将其拖拽到Eclip ...

  7. 关于Unity中如何代码动态修改天空盒

    在Unity中动态修改天空盒有两种方法: 一.为每个Texture建立天空盒材质球,需要更换时直接将对应材质球作为天空盒,缺点是建立的材质球太多 private void ChangeSkybox(M ...

  8. E - Elevator

    E - Elevatorhttp://codeforces.com/gym/241680/problem/E同余最短路,从0~a-1中每一个i向(i+b)%a连一条权值为b的边,向(i+c)%a连一条 ...

  9. open-falcon之使用mail-provider发邮件(支持smtp SSL协议)

    一.首先确定go语言安装环境配置好 1.进入官网下载源码包 https://golang.org/dl/ 2.解压缩,配置环境变量 在/etc/profile最后加上export PATH=$PATH ...

  10. &lpar;转&rpar;C&num; Windows服务 弹出消息提醒框

    出处:http://blog.csdn.net/donghui6116773/article/details/53467069 服务(Service)对于大家来说一定不会陌生,它是Windows 操作 ...