Ascii codec can't encode

Ulrich Eckhardt eckhardt at
Thu Oct 30 10:02:35 CET 2008

luca72 wrote:
> hello i have this problem:
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
> position 8: ordinal not in range(128)

This is the result of transcoding a Unicode string to ASCII, where the
Unicode string contains a character that is not representable in ASCII.
This happens to me when I try to print such a character because my console
is set to ASCII.

> Generally i solve the problem inserting :
> # -*- coding: ISO-8859-1 -*-
> at the top of the file but now he don't work can you help me

This only tells Python that your sourcecode uses Latin 1 as encoding. It
doesn't affect other files or any input or output streams.

What code exactly triggers the error?


Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

More information about the Python-list mailing list