新手在这里。我正在使用python学习电子邮件分析。我正在尝试将文件转换为CSV。我正在使用的代码如下:
with open('mbox.csv','w') as outfile:
writer=csv.writer(outfile)
writer.writerow(['subject','from','to','date'])
for message in mbox:
writer.writerow([message['Subject'],message['from'],message['to'],message['date']])
我不断出错:
UnicodeEncodeError: 'charmap' codec can't encode characters in position 108-110: character maps to <undefined>.
尽管似乎已创建CSV文件,但我对该错误感到困扰。