[Tutor] COnvert a string?

j2 spamfilter2@mupp.net
Sun Jul 6 07:18:01 2003


> look at decode_header function in email package
> i've used:

Ok, i did

#!/usr/bin/python2.2
import string
import email

x =
"=?iso-8859-1?Q?Hej=2C_tack_f=F6r_bra_team_work_p=E5_ndc5_i_fredags_efterm?=
=?iso-8859-1?Q?iddag!_/Rolf?="

y = email.Header.decode_header(x)
s = u''
for text, charset in header_line:
        if charset:
                try:
                        s += text.decode(charset)
                except:
                        s += text
        else:
                s += text


and i get

cookiemonster:/root/scripts# ./test.py
Traceback (most recent call last):
  File "./test.py", line 15, in ?
    y = email.Header.decode_header(x)
AttributeError: 'module' object has no attribute 'Header'
cookiemonster:/root/scripts#

any hints?