当前位置:网站首页>Resolved Unicode decodeerror: 'UTF-8' codec can't decode byte 0xa1 in position 0: invalid start byte
Resolved Unicode decodeerror: 'UTF-8' codec can't decode byte 0xa1 in position 0: invalid start byte
2022-07-28 00:53:00 【No envy】
resolved (Python Read csv File error )UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xa1 in position 0: invalid start byte
List of articles
Error code
My code :
import pandas as pd
import numpy as np
df = pd.read_csv('test.csv')
print(df)
Error message :
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xa1 in position 0: invalid start byte
Error reason
Translation of error reporting content :
UnicodeDecodeError:“utf-8” Codec can't decode location 0 Bytes in 0xa1: Invalid start byte
Error reason :CSV The document is not UTF-8 Encoding , It's about using gbk Coded .
Solution method
resolvent (1):
1. Choose csv file -》 Right mouse button -》 Open mode -》 Choose Notepad
2. Open the file and select “ file ” -》" Save as “, We can see that the default code is :
ANSI
3. choice UTF-8 Click save , If you run the program again, you won't report an error
resolvent (2): The coding format of the modified code is gbk
import pandas as pd
import numpy as np
df = pd.read_csv('test.csv',encoding="gbk")
print(df)
Run again successfully :

边栏推荐
- At least 42 employees are infected with novel coronavirus! Nokia announces closure of telecom equipment plant in India
- 递归求解迷宫问题
- LeetCode_ Bit operation_ Medium_ 137. Number II that appears only once
- Set 数据构造函数
- Volkswagen China invested 8billion yuan and became the largest shareholder of GuoXuan high tech
- 《KMP复习 + AC自动机》前传
- Point divide and conquer analysis
- In the first quarter of 2020, the wearable market shipped 72.6 million units, with apple occupying nearly 30% of the market share
- [proteus simulation] 51 single chip microcomputer washing machine simulation control program
- Buildforge materials
猜你喜欢

LeetCode 415. 字符串相加 和 43. 字符串相乘

芯片行业常用英文术语最详细总结(图文快速掌握)

map集合

Set 数据构造函数

The program design questions of the 11th national competition of Bluebridge cup single chip microcomputer

Basic operations of MySQL database (3) --- Based on fields

Buildforge materials

一文读懂CMake

Postman download and use tutorial

小波变换学习笔记
随机推荐
Buildforge materials
Logic of automatic reasoning 09 - automatic theorem proving
相应通道无电压但ADC的值却在大幅变化且不等于0的可能原因
基本初等函数
网络设备硬核技术内幕 防火墙与安全网关篇 (十一) 零接触办公的奥秘 上
592. 分数加减运算 : 表达式计算入门题
网络设备硬核技术内幕 防火墙与安全网关篇 (小结)
小程序助力智能家居生态平台
Network equipment hard core technology insider firewall and security gateway chapter (VI) security double repair under the law
mysql数据库的基本操作(一)-——基于数据库
Valued at $36billion! SpaceX, which is about to launch its first manned launch, raised $346million
Data analysis: disassembly method (details)
numpy没有unsqueeze函数
Count the six weapons of the domestic interface cooperation platform!
Interesting Huffman tree
Intel AI practice day issue 56 | explore new trends in industry development
The Canadian court found Meng Wanzhou guilty of "dual criminality", and the extradition procedure will continue!
Basic operations of MySQL database (I) --- Based on Database
Network equipment hard core technology insider firewall and security gateway (11) secrets of zero contact office
有趣的哈夫曼树