我之前已经在python中多次打开和读取csv文件,但是由于某种原因,这次我一直收到此错误。
错误:
File "C:\Program Files\Python37\lib\encodings\cp1250.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 22: character maps to <undefined>
我的代码:
with open("databa.csv", 'r') as fp:
for line in fp:
print(line)
我已经尝试过重命名文件,将格式设置为'UTF8'或忽略错误(“ databa.csv”,“ r”,errors ='ignore“),但没有一个起作用
with open(r"databa.csv", 'rb') as fp:
with open("databa.csv", 'r', buffering=0) as fp:
with open("databa.csv", errors="ignore") as fp:
with open("databa.csv",encoding='utf8', errors="ignore") as fp:
with open("databa.csv",encoding='utf8', "r") as fp:
with open("databa.csv", encoding='utf8', "r") as fp