On 2017-01-13, D'Arcy Cain <da...@vybenetworks.com> wrote:

> Here is the failing code:
>
> with open(sys.argv[1], encoding="latin-1") as fp:
>    for ln in fp:
>      print(ln)
>
> Traceback (most recent call last):
>    File "./load_iff", line 11, in <module>
>      print(ln)
> UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in 
> position 132: ordinal not in range(128)
>
> I don't understand why the error says "ascii" when I told it to use 
> "latin-1".

That can't be the failing code, since it's failing at line 11, and
that's only 5 lines. It helps if we can tell which line generated the
error.  ;)

I'm _guessing_ that line 11 is the print(), and it's barfing because
stdout is using ascii encoding, and there's no way to encode that
character in ascii so that it can be printed to an ascii output
stream.

-- 
Grant Edwards               grant.b.edwards        Yow! Everybody gets free
                                  at               BORSCHT!
                              gmail.com            

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to