[Tutor] Using the structs module for the first time
Tony Cappellini
tony at tcapp.com
Thu Nov 18 00:01:01 CET 2004
Thanks Lloyd
BAsed on your answer, I'll assume there's no way to have unpack() format
the resulting tuple in hex, and that post-processing is the only way to
get the results in hex.
I had already looked in the library reference for formatting options for
the struct module, but
didn't see anything obvious.
On Wed, 17 Nov 2004, Lloyd Kvam wrote:
> 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