Hey bit of a beginners question here, I have connected to an imap server using the imaplib and fetched a email, it returns the following:
[('1 (BODY[HEADER.FIELDS (SUBJECT)] {62}', "Subject: Gmail is different. He开发者_如何学Gore's what you need to know.\r\n\r\n"), ')']
My question is how do I select just the subject element ("Subject: Gmail is...").
I have tried a few combinations but yet to be successful.
Thanks for any help!
a[0][1]
where a is the string.
email=[('1 (BODY[HEADER.FIELDS (SUBJECT)] {62}', "Subject: Gmail is different. Here's what you need to know.\r\n\r\n"), ')']
for subj in (subject for element in email for subject in element if subject.startswith("Subject")):
print subj
""" Output
Subject: Gmail is different. Here's what you need to know.
"""
精彩评论