Spanish Accents

Chris Angelico rosuav at gmail.com
Thu Dec 22 09:58:43 EST 2011


On Fri, Dec 23, 2011 at 1:55 AM, Stan Iverson <iversonstan at gmail.com> wrote:
> Hi;
> If I write a python page to print to the web with Spanish accents all is
> well. However, if I read the data from a text file it prints diamonds with
> question marks wherever there are accented vowels. Please advise.

Sounds like an encoding problem.

Firstly, are you using Python 2 or Python 3? Things will be slightly
different, since the default 'str' object in Py3 is Unicode.

I would guess that your page is being output as UTF-8; you may find
that the solution is as easy as declaring the encoding of your text
file when you read it in.

ChrisA



More information about the Python-list mailing list