通过Google App Engine接收带有.csv附件的邮件
我已经能读取邮件了,也能看到附件,但附件的格式不是.csv的数据。我猜它可能是“EncodedPayload”类型?
下面的代码:
for filename, content in attachments:
logging.info("filename: " + filename)
fileReader = csv.reader(content.split("\n"))
给我报了这个错:
'EncodedPayload' object has no attribute 'split'
我该怎么处理一个EncodedPayload格式的csv文件呢?
1 个回答
1
在你的内容上调用 decode()
这个函数:
fileReader = csv.reader(content.decode())