[Tutor] COnvert a string?
Michal Molhanec
molhanec@seznam.cz
Sun Jul 6 06:56:02 2003
j2 wrote:
> Ok, i am not a _total_ newbie (just almost). But i need to convert a
> string that looks a little something like this
>
> =?iso-8859-1?Q?Hej=2C_tack_f=F6r_bra_team_work_p=E5_ndc5_i_fredags_efterm?=
> =?iso-8859-1?Q?iddag!_/Rolf?=
>
> into a "plain" textfile (ASCII text only, with spaces between words).
> Any hints? I can not figure this out?
look at decode_header function in email package
i've used:
header_line = email.Header.decode_header(header_line)
s = u''
for text, charset in header_line:
if charset:
try:
s += text.decode(charset)
except:
s += text
else:
s += text
warning: i'm also only beginner