[Baypiggies] hex dump in Python 3

Tung Wai Yip tungwaiyip at yahoo.com
Mon Jan 31 03:40:29 CET 2011


This can be done in 1 line. Just use .encode('hex')

e.g.

>>> open('64_64.gif','rb').read(10).encode('hex')
'47494638396140004000'




> Does anyone have a sample hex-dump routine for Python3? I'm trying to
> recover data from a BlackBerry backup file, & I need to "see" the bytes  
> I'm
> reading from the  backup file,which don't  appear to match the format  
> I've
> found. Something showing the offset, char-hex, and printable chars (or
> periods), such as:
>
> bs = f.read(flen)
> hexdump(bs)
> 00000000 01020304050607083031323334353637 ........01234567
> 00000010 4142436162                       ABCab


More information about the Baypiggies mailing list