使用unicode编码时出错

2024-09-25 00:23:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用unicodesv模块将一个列表写入csv文件,用“utf-8”编码,但是当我尝试使用unicodesv.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)

当我试着读的时候:

^{pr2}$

我收到了错误信息。在


Tags: 模块文件csvtocsvfile编码列表错误