1
我有一个非常简单的代码,需要一个CVS并将其放入二维数组中。它在Python2上运行良好,但在Python3中,我得到下面的错误。翻翻文件,我想我需要使用.decode()可能有人请解释如何在我的代码的情况下使用它,所以我不需要Python2python 3 read csv UnicodeDecodeError
Error: line 21, in for row in datareader: File "/usr/lib/python3.6/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 5002: invalid start byte
import csv
import sys
fullTable = sys.argv[1]
datareader = csv.reader(open(fullTable, 'r'), delimiter=',')
full_table = []
for row in datareader:
full_table.append(row)
print(full_table)
做任何事