我使用unicodecsv模块将列表写入csv文件,用“utf-8”编码,但是当我尝试使用unicodecsv.reader读取它时,我仍然收到错误:UnicodeDecodeError: 'utf8' codec can't decode byte...
。我可以通过csv.reader阅读它。有什么东西我错过了吗?
我的代码是这样的:
with open(datapath + filename, 'wb') as csvfile:
writer_to_csv = unicodecsv.writer(csvfile, encoding = "utf-8")
writer_to_csv.writerows(data)
当我尝试阅读时:
with open(datapath + filename, 'rb') as csvfile:
file_to_list = unicodecsv.reader(csvfile, encoding = "utf-8")
我收到了错误消息。