I'm working on a program that is supposed to save
different information to text files.
Because the program is in swedish i have to use
unicode text for ÅÄÖ letters.
When I run the following testscript I get an error message.
# -*- coding: cp1252 -*-
titel = "åäö"
titel = unicode(titel)
print "Titel type", type(titel)
fil = open("testfil.t xt", "w")
fil.write(titel )
fil.close()
Traceback (most recent call last):
File "D:\Documen ts and
Settings\Daniel \Desktop\Progra mmering\aaotest \aaotest2\aaote st2.pyw",
line 5, in ?
titel = unicode(titel)
UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0xe5 in position 0:
ordinal not in range(128)
I need to have the titel variable in unicode format because when I
write
åäö in a entry box in Tkinkter it makes the value to a unicode
format
automaticly.
Are there anyone who knows an easy way to save this unicode format text
to a file?
different information to text files.
Because the program is in swedish i have to use
unicode text for ÅÄÖ letters.
When I run the following testscript I get an error message.
# -*- coding: cp1252 -*-
titel = "åäö"
titel = unicode(titel)
print "Titel type", type(titel)
fil = open("testfil.t xt", "w")
fil.write(titel )
fil.close()
Traceback (most recent call last):
File "D:\Documen ts and
Settings\Daniel \Desktop\Progra mmering\aaotest \aaotest2\aaote st2.pyw",
line 5, in ?
titel = unicode(titel)
UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0xe5 in position 0:
ordinal not in range(128)
I need to have the titel variable in unicode format because when I
write
åäö in a entry box in Tkinkter it makes the value to a unicode
format
automaticly.
Are there anyone who knows an easy way to save this unicode format text
to a file?
Comment