当前位置:网站首页>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 :

边栏推荐
- Matlab | matlab terrain generation: rectangular iteration method, inverse Fourier transform method, fractal Berlin noise method
- How to smoothly go online after MySQL table splitting?
- 有趣的哈夫曼树
- MySQL limit usage and large paging problem solving
- [proteus simulation] 51 single chip microcomputer washing machine simulation control program
- Jericho will make a popping sound when turning on, broadcasting a prompt tone, and turning off [chapter]
- Confused SCM matrix keys
- map集合
- R language evaluates the relative importance of the predictive factors (variables, characteristics) of the regression model, scales the predictive variables of the regression model, and then construct
- 阿里二面:为什么要分库分表?
猜你喜欢

Data analysis: disassembly method (details)

FFT 采样频率和采样点数的选取

《KMP复习 + AC自动机》前传

Intel AI practice day issue 56 | explore new trends in industry development

Jmeter 如何解决乱码问题?

How does JMeter solve the problem of garbled code?

startUMl

蓝桥杯单片机第十一届国赛程序设计试题
![Jericho will make a popping sound when turning on, broadcasting a prompt tone, and turning off [chapter]](/img/e3/ea7278eb855cca2a1af4f96772bcb1.png)
Jericho will make a popping sound when turning on, broadcasting a prompt tone, and turning off [chapter]
![[leetcode] 547. Number of provinces (medium)](/img/15/d49d18151c47e318fe7acabdd616e6.png)
[leetcode] 547. Number of provinces (medium)
随机推荐
Current situation of semiconductor testing equipment Market: the localization rate is still less than 10%!
Recurrence of fastjson historical vulnerabilities
迷惑的单片机矩阵按键
Jerry's Bluetooth can only link back to the last device [article]
Impulse attends the 2022 Forum on safe circulation of data elements Online - a special session in the field of government affairs, and helps the construction and innovative development of big data for
大众中国豪掷80亿,成国轩高科第一大股东
How does JMeter solve the problem of garbled code?
Network equipment hard core technology insider firewall and security gateway chapter (VI) security double repair under the law
数据可视化-《白蛇2:青蛇劫起》(3)
Basic operations of MySQL database (2) --- Based on data table
网络设备硬核技术内幕 防火墙与安全网关篇 (九) 虚拟化神器 (下)
Code review tool
LeetCode - 寻找两个正序数组的中位数
Syntaxerror resolved: positive argument follows keyword argument
҈ straight ҈ Broadcast ҈ Pre ҈ Report ҈ |҈ In hot summer, let's cross the high temperature and "bake" with nono!
MySQL中的运算符
Build Release Blogs
网络设备硬核技术内幕 防火墙与安全网关篇 (七) 虚拟化神器 (上)
LeetCode_位运算_中等_137.只出现一次的数字 II
Basic elementary function