【发布时间】:2015-03-03 06:38:40
【问题描述】:
我正在开发一个在 windows 下用 python 编写的程序。它正在读取 cvs 文件。以下是部分代码:
with open(os.path.abspath(self.currencies_file_path), 'r') as f:
reader = csv.reader(f)
#for each row find whether such isocode exists in the table
for row in reader: #THis is line 49
这是错误:
File "whatever/staticdata.py", line 49, in upload_currencies
for row in reader:
File "/usr/lib/python3.4/codecs.py", line 313, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 1307: invalid continuation byte
csv 文件甚至没有用 utf-8 编码(我认为)。为什么我会遇到这种问题?
附:我对编码一无所知。
【问题讨论】:
-
你知道编码文件是用什么写的吗?
-
@user590028 不知道有没有办法确定?
-
我认为是 latin1。