newbie parsing question
Paul McGuire
ptmcg at austin.rr._bogus_.com
Sat Mar 25 12:40:23 EST 2006
"Kun" <neurogasm at gmail.com> wrote in message
news:e022qp$eou1$1 at netnews.upenn.edu...
> i have a list of that is:
>
> [('460 (BODY[HEADER.FIELDS (FROM)] {46}', 'From: Friend
> <anon at anon.com>\r\n\r\n'), ')', ('462 (BODY[HEADER.FIELDS (FROM)] {37}',
> 'From: Kun <neurogasm at gmail.com>\r\n\r\n'), ')']
>
>
> how do i parse the email addresses out of it into another list or string?
data = [('460 (BODY[HEADER.FIELDS (FROM)] {46}',
'From: Friend <anon at anon.com>\r\n\r\n'), ')',
('462 (BODY[HEADER.FIELDS (FROM)] {37}',
'From: Kun <neurogasm at gmail.com>\r\n\r\n'), ')']
for s in data:
if type(s) is tuple:
print s[1][6:].strip().split()[1]
Gives:
<anon at anon.com>
<neurogasm at gmail.com>
-- Paul
More information about the Python-list
mailing list