Spanish Accents

Chris Angelico rosuav at gmail.com
Thu Dec 22 11:35:54 EST 2011


On Fri, Dec 23, 2011 at 3:22 AM, Stan Iverson <iversonstan at gmail.com> wrote:
>
> On Thu, Dec 22, 2011 at 11:30 AM, Rami Chowdhury <rami.chowdhury at gmail.com> wrote:
>>
>> Could you try using the 'open' function from the 'codecs' module?
>
> I believe this is what you meant:
>
> file = codecs.open(p + "2.txt", "r", "utf-8")
>
> but got this error:
>
>  /usr/lib64/python2.4/codecs.py in next(self=<open file 'index2.txt', mode 'rb'>)

Your file almost certainly isn't UTF-16, so don't bother trying that.
I think you may have ISO-8859-1 encoding, also called Latin-1, but
it's not easy to be sure. Try:

file = codecs.open(p + "2.txt", "r", "iso-8859-1")

ChrisA



More information about the Python-list mailing list