Trouble saving unicode text to file
"Martin v. Löwis"
martin at v.loewis.de
Sun May 8 05:23:49 EDT 2005
Svennglenn wrote:
> # -*- coding: cp1252 -*-
>
> titel = "åäö"
> titel = unicode(titel)
Instead of this, just write
# -*- coding: cp1252 -*-
titel = u"åäö"
> fil = open("testfil.txt", "w")
> fil.write(titel)
> fil.close()
Instead of this, write
import codecs
fil = codecs.open("testfil.txt", "w", "cp1252")
fil.write(titel)
fil.close()
Instead of cp1252, consider using ISO-8859-1.
Regards,
Martin
More information about the Python-list
mailing list