Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28205

Re: to know binary

Date 2012-09-01 01:29 -0400
From Dave Angel <d@davea.name>
Subject Re: to know binary
References <CA+YdQ_44L840OJ3H49wARV_sio67dmBtYzuyraHrRbdOA6urpQ@mail.gmail.com> <504191D4.8010300@davea.name> <CA+YdQ_4v+hNsSh5B0kU04mLzK+0OHO-cSs++fgRQyitDV68cGQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.25.1346477391.27098.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: to know binary Dave Angel <d@davea.name> - 2012-09-01 01:29 -0400

csiph-web