'utf-8' codec can't decode byte 0xf8 in position 14: invalid start byte
时间: 2023-08-14 18:02:40 浏览: 117
basemap readshapefile UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position 0-附件资源
回答: 当你遇到"'utf-8' codec can't decode byte 0xf8 in position 14: invalid start byte"错误时,可能是因为你的文件编码格式不是UTF-8,而你尝试用UTF-8解码。解决这个问题有几种方法。首先,你可以查看你对应文件的编码格式,使用notepad查看文件的编码格式。如果你知道了你的文件编码格式,那么你可以用对应编码格式打开文件,比如使用utf-16编码格式打开文件:data = pd.read_table('data.txt',encoding='utf-16')。另外,浏览器在访问网页时会自动解压缩从服务器中返回的gzip压缩的网页,所以添加"Accept-Encoding" = “gzip,deflate,br”没出错。而我们编写的代码中,没有自动解码压缩后的数据,将压缩后的数据当做普通的html文本来处理,可能会导致乱码。还有一种解决方法是在读取文件时添加判定条件,比如使用split判断文件后缀,只处理后缀为csv的文件。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [‘UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xff in position 0: invalid start byte...](https://blog.csdn.net/qq_41981894/article/details/118390202)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [UnicodeDecodeError: utf-8 codec can t decode byte 0x8b in position 1: invalid start byte](https://blog.csdn.net/m0_52613986/article/details/129739448)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [ ‘utf-8‘ codec can‘t decode byte 0xff in position 0: invalid start byte](https://blog.csdn.net/weixin_51143190/article/details/126125099)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文