UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 16: invalid start byte

时间:2022-12-30 20:53:33

 

读取一个csv文件失败,提示:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 16: invalid start byte

 

解决办法:使用Notepad++打开该csv文件,然后转为UTF-8编码

 

1 import csv
2 csv_reader=csv.reader(open('P020180206560372967623.csv',encoding='utf-8'))
3 for row in csv_reader:
4     print(row)