Unicode issue with Python v3.3

Cameron Simpson cs at zip.com.au
Thu Apr 11 06:45:22 EDT 2013


On 10Apr2013 21:50, nagia.retsina at gmail.com <nagia.retsina at gmail.com> wrote:
| Firtly thank uou for taking a look into the code.
| the doctype is coming form the attempt of script metrites.py to open and read the 'index.html' file.
| But i don't know how to try to open it as a byte file instead of an tetxt file.

I think you've got it backwards. It looks like metrites.py has
opened the file as bytes instead of as text (probably utf8, but
that remains to be seen). Because it has opened it in binary mode
you're getting bytes when you read from the file.

Can you show the relevant code that opens the files and reads from
it, and the print statement that is putting it back out?

You probably need to ensure that metrites.py is opening it as text,
with the correct encoding.  Note that the encoding is nothing to
do with your _output_. It is the encoding of the data in the file
you are reading, and that is dictated by the editor used to make
the file.

Anyway, code first. What does it look like?

Cheers,
-- 
Cameron Simpson <cs at zip.com.au>

Six trillion RFID tags is four orders of magnitude bigger than any electronic item ever made.
- overhead by WIRED at the Intelligent Printing conference Oct2006



More information about the Python-list mailing list