我是新手。我正在学习使用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文件是被创建的,但我还是为这个错误而烦恼。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐