Email 通过python 3.4获取电子邮件正文

Email 通过python 3.4获取电子邮件正文,email,python-3.4,Email,Python 3.4,我想要电子邮件的正文。我的电子邮件是html格式的,部分保存。使用此代码: print('charset =', part.get_content_charset()) html = part.get_payload(decode=True) print ('type =', type(html)) print('text =', html) 结果是: charset = utf-8 type = <class 'bytes'> text = b'...<font face=

我想要电子邮件的正文。我的电子邮件是html格式的,部分保存。使用此代码:

print('charset =', part.get_content_charset())
html = part.get_payload(decode=True)
print ('type =', type(html))
print('text =', html)
结果是:

charset = utf-8
type = <class 'bytes'>
text = b'...<font face="DejaVu Sans Mono">\\u044d\\u0442\\u043e html<br>\n...
charset=utf-8
类型=
text=b'…\\u044d\\u0442\\u043e html
\n。。。
我想要普通文本,但没有\u044d\u0442\u043e


win32上的Python 3.4.1(v3.4.1:c0e311e010fc,2014年5月18日,10:38:22)[MSC v.1600 32位(英特尔)]您的数据是字节数组。您必须将字节解码为字符串:

text.decode('utf-8')
这不起作用,结果=
\\u044d\\u0442\\u043e html
\n