[IPython-user] How to display the content of a string in hexadecimal format?

Ville M. Vainio vivainio@gmail....
Sun Sep 7 04:50:22 CDT 2008

On Sun, Sep 7, 2008 at 11:11 AM, ray <hantechs@gmail.com> wrote:
> For example, if the content of a string is 'abc', I want to a output like
> 414243. Is there a easy way? Thanks in advance.

[C:opt/Console2]|2> ' '.join(hex(ord(ch)) for ch in 'abc')
                <2> '0x61 0x62 0x63'

[C:opt/Console2]|3> ''.join(hex(ord(ch))[2:] for ch in 'abc')
                <3> '616263'

There is no "ipython shortcut" for this though.

Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'

More information about the IPython-user mailing list