to know binary

Dave Angel d at davea.name
Sat Sep 1 01:29:26 EDT 2012


On 09/01/2012 12:59 AM, contro opinion wrote:

1) you top-posted
2) you replied privately, excluding the list from your query

> the file is utf-8 format,
>>>> str='/0x31/0x32/0x33/0x34'

3) No idea what that value is supposed to mean.  Perhaps you intended to
use backslashes here?  And perhaps you meant to omit the zeroes?

>>>>
> why  unicode(str,"utf-8").encode("utf-8")  can not get  1234?
> 

It gets a string, not an integer.  And the string will be "1234" once
you fix the problems in the earlier line.

While you're at it, you should pick a better name for your string.  str
already has a meaning in Python, and you're hiding that.  No real harm
other than readability, but it'll be embarrassing when you actually need
to use the str() function and you end up trying to call your string.

Still not sure how to interpret your original message.  You said nothing
about unicode, or conversions.

And I've been assuming you're using Python 2.x, but all this will be
different for 3.x

-- 

DaveA



More information about the Python-list mailing list