我正在尝试在python中读取非英语.csv
文件,但我面临编码错误。能帮我解决这个问题吗?
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xae in position 53587: invalid start byte
使用的代码:
import pandas as pd
with open('1.csv', encoding="utf-8") as f:
train = f.read().splitlines()
print(train)
答案 0 :(得分:1)
实际上,我认为您的文件编码不合适。我在下面的代码中使用了许多波斯的csv文件,并且可以正常工作!
import csv
with open('file.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
for row in csv_reader:
print(row)