这是我的actula代码:
import poplib, sys, re, threading, time, Queue
from email import parser
Mailbox = poplib.POP3(pop3, '110')
Mailbox.user(username)
Mailbox.pass_(password)
numMessages = len(Mailbox.list()[1])
for i in range(numMessages):
fullemail = ''
fullemail = '\n'.join([msg for msg in Mailbox.retr(i+1)[1]])
msg = parser.Parser().parsestr(fullemail)
for part in msg.walk():
print part.get_payload(decode=True)
打印part.get_payload(decode = True)打印电子邮件正文,如何打印电子邮件标题?
答案 0 :(得分:0)
items()
/ email.message.Message
对象的方法email.message.EmailMessage
可能有用:
for t in msg.items():
print(t)
t是一个像这样的元组(key,value).