ordinal not in range

Jaap van Wingerde mailinglists at vanwingerde.net
Sat Feb 21 09:43:37 EST 2009


Stefan Behnel wrote:
> 	Omschrijving = Omschrijving.replace("priv?", 'privé')

I Thank you, this works now, but I get a new error message.

....
import codecs
file = "postbank.csv"
output = "%s.eb" % file
outfile = codecs.open(output, "w", "utf_8")
Omschrijving = u'priv? assuranti?n' # string from postbank.csv
Omschrijving = Omschrijving.replace("priv?", 'privé')
Omschrijving = Omschrijving.replace("Assuranti?n", 'Assurantiën')
outfile.write (Omschrijving)

"Traceback (most recent call last):
   File "/home/jaap/Desktop/unicode.py", line 9, in <module>
     outfile.write (Omschrijving)
   File "/usr/lib/python2.5/codecs.py", line 638, in write
     return self.writer.write(data)
   File "/usr/lib/python2.5/codecs.py", line 303, in write
     data, consumed = self.encode(object, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 4: 
ordinal not in range(128)"








More information about the Python-list mailing list