Sujet : Re: How to manage accented characters in mail header?
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.pythonDate : 04. Jan 2025, 20:40:34
Autres entêtes
Organisation : Stefan Ram
Message-ID : <parseaddr-20250104204008@ram.dialup.fu-berlin.de>
References : 1 2 3
Chris Green <
cl@isbd.net> wrote or quoted:
print(final_string)# From: Sébastien Crignon <sebastien.crignon@amvs.fr>
Is there a simple[r] way to extract just the 'real' address between
the <>, that's all I actually need. I think it has the be the last
chunk of the From: doesn't it?
Besides the deal with the pointy brackets, there's also this
other setup with round ones, like in
sebastien.crignon@amvs.fr (Sébastien Crignon)
. The standard library has:
email.utils.parseaddr(address)
Parse address – which should be the value of some
address-containing field such as To or Cc - into its
constituent realname and email address parts. Returns a tuple
of that information, unless the parse fails, in which case a
2-tuple of ('', '') is returned.
.