ensnare
ensnare

Reputation: 42043

In Python, identify parts of an e-mail address

Given a list of e-mail addresses:

list = ('First Last <[email protected]>' , '[email protected]')

some of which contain first and last name, others which just contain an e-mail address, how can I loop through the list and extract a first and last name (if they exist), and the email address?

Thanks.

Upvotes: 2

Views: 423

Answers (1)

user470379
user470379

Reputation: 4889

import email.utils
map(email.utils.parseaddr, email_list)

Upvotes: 9

Related Questions