【发布时间】:2011-04-30 14:25:07
【问题描述】:
我正在编写一个处理传入邮件的 Google App 引擎应用程序,这是我目前用于处理邮件消息的代码:
for content_type, body in email_bodies:
#8bit bug in mail messages - see bug report here
#http://code.google.com/p/googleappengine/issues/detail?id=2383
if body.encoding == '8bit':
body.encoding = '7bit'
#test for html content
if content_type == "text/html":
#parse html result
if content_type == "text/plain":
decoded_msg_body = body.decode()
但是,我刚刚收到一条使用二进制编码方案的消息,当我的程序尝试使用 body.decode() 处理该消息时,我收到了 UnknownEncodingError。这个程序应该如何解析二进制内容类型?另外,如何在本地版本的 GAE 上模仿这种消息类型,以便调试和测试它?
感谢您的帮助, 凯文
【问题讨论】:
标签: python google-app-engine email encoding binary