从我的脚本输出数据时遇到问题:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 14: ordinal not in range(128)
这是输出数据的代码:
zipped = zip(list_1, list_2, list_3, list_4, list_5)
with open('my_file.csv', 'rb') as infile, open('my_out_file.csv', 'wb') as outfile:
reader = csv.reader(infile)
writer = csv.writer(outfile)
for i, row in enumerate(reader):
row.extend(zipped[i])
writer.writerow(row)
经过一番搜索,我意识到我必须手动将其编码为UTF8,但我无法弄清楚如何。任何帮助表示赞赏。