[Tutor] Using the structs module for the first time

Lloyd Kvam pythonTutor at venix.com
Wed Nov 17 23:03:59 CET 2004


Python's format string operater can do what you need.
>>> '%x' % 128
'80'

	print ['%x' % x for x in unpacked_from_struct]
provides a simple view.  

See the string formating section of the Library Reference for fancier
options.

On Wed, 2004-11-17 at 15:56, Tony Cappellini wrote:
> I've been able to get a string to unpack showing the correct values, I
> would like to display the unpacked values in hex.
> 
> Is there a formatting code for the structs module to display the returned
> tuple from unpack() in hex, or do I have to manually post-process the data
> ?
> 
> thanks
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-- 
Lloyd Kvam
Venix Corp



More information about the Tutor mailing list