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


Groups > comp.lang.python > #46417

Re: python b'...' notation

Date 2013-05-30 08:19 +1000
From Cameron Simpson <cs@zip.com.au>
Subject Re: python b'...' notation
References <CALwzid=mdbD5n2-08uAsD5eRub3FadEOBYVS4NWmCQy7W+-XXQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2384.1369866008.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 29May2013 13:14, Ian Kelly <ian.g.kelly@gmail.com> wrote:
| On Wed, May 29, 2013 at 12:33 PM, alcyon <steve@terrafirma.us> wrote:
| > This notation displays hex values except when they are 'printable', in which case it displays that printable character.  How do I get it to force hex for all bytes?  Thanks, Steve
| 
| Is this what you want?
| 
| >>> ''.join('%02x' % x for x in b'hello world')
| '68656c6c6f20776f726c64'

Not to forget binascii.hexlify.
-- 
Cameron Simpson <cs@zip.com.au>

Every particle continues in its state of rest or uniform motion in a straight
line except insofar as it doesn't.      - Sir Arther Eddington

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


Thread

Re: python b'...' notation Cameron Simpson <cs@zip.com.au> - 2013-05-30 08:19 +1000
  Re: python b'...' notation alcyon <steve@terrafirma.us> - 2013-05-30 15:19 -0700
    Re: python b'...' notation jmfauth <wxjmfauth@gmail.com> - 2013-05-31 00:51 -0700

csiph-web