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


Groups > comp.lang.python > #46408

Re: python b'...' notation

References <17dc2765-bc59-407a-9227-d67572411ad1@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2013-05-29 13:14 -0600
Subject Re: python b'...' notation
Newsgroups comp.lang.python
Message-ID <mailman.2377.1369854893.3114.python-list@python.org> (permalink)

Show all headers | View raw


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'

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


Thread

python b'...' notation alcyon <steve@terrafirma.us> - 2013-05-29 11:33 -0700
  Re: python b'...' notation Ian Kelly <ian.g.kelly@gmail.com> - 2013-05-29 13:14 -0600

csiph-web