UnicodeDecodeError: 'gb2312' codec can't decode bytes in position 723269-723270: ille
16lz
2021-01-22
pycharm控制台中文乱码,目标网页编码gb2312编码
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
网上还很说是先转成gb2312转换unicode成再转成utf-8。
html = response.read().decode("gb2312").encode("utf-8") 运行出错 UnicodeDecodeError: 'gb2312' codec can't decode bytes in position 723269-723270: illegal multibyte sequence 去掉
decode("gb2312").encode("utf-8" 直接
html = response.read()
在linux终端运行python index.py显示网页正常然后排查pycharmIDE控制台编码问题
修改ctrl+alt+s Editor--File Encoding Global Encoding 设置成GBK,显示正常。
猜测:控制台的编码需要跟win保持一致
更多相关文章
- python python 入门学习之网页数据爬虫cnbeta文章保存
- 用 Python requests库 爬取网页数据
- python爬网页,做k线图
- 【python 编程】网页中文过滤分词及词频统计
- Python MOOC简单获取网页内容并以html格式保存在本地
- 【Python】python3实现网页爬虫下载图片
- python进阶——利用网页爬虫写天气预报采集器
- java根据URL获取网页编码
- 使用Java在网页中的许多可能选择中选择一个