Unicode issue with Python v3.3

Cameron Simpson cs at zip.com.au
Wed Apr 10 19:17:22 EDT 2013


On 10Apr2013 01:06, Νίκος Γκρ33κ <nikos.gr33k at gmail.com> wrote:
| Here is the whole code for metrites.py in case someone wants to take allok.
| 
| Everything is correct after altering it to meet python 3.3,
| everythign aprt from the weird unicode error thing.
| 
| http://pastebin.com/5Mpjx5Fd
| 
| please take a look.

From looking at the HTML source of the page:

  http://superhost.gr/

I see near the start:

  b'<!DOCTYPE html

I'd say you have a bytes object that you've fed to print().
In python2, str is effectively bytes.
In python3, str is a sequence of Unicode code points, and bytes are
arrays of small integers.
If you feed a bytes object to print it will print a strig represenation
of it, starting with "b'...".

The question is: where did the bytes object come from? A cursory
glance through your pastebin code doesn't show me anthing very
obvious.

I'd start by asking: where does the string "<!DOCTYPE" come from?
Wherever that is, it seems to be bytes rather than str.
Start with that.

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

You don't have to live on the edge, but you have to know where it is.
        - Scott Lilliott, csl at swl.msd.ray.com



More information about the Python-list mailing list