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


Groups > comp.lang.python > #46404 > unrolled thread

python b'...' notation

Started byalcyon <steve@terrafirma.us>
First post2013-05-29 11:33 -0700
Last post2013-05-29 13:14 -0600
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  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

#46404 — python b'...' notation

Fromalcyon <steve@terrafirma.us>
Date2013-05-29 11:33 -0700
Subjectpython b'...' notation
Message-ID<17dc2765-bc59-407a-9227-d67572411ad1@googlegroups.com>
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

[toc] | [next] | [standalone]


#46408

FromIan Kelly <ian.g.kelly@gmail.com>
Date2013-05-29 13:14 -0600
Message-ID<mailman.2377.1369854893.3114.python-list@python.org>
In reply to#46404
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'

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web