[Tutor] str format conversion help
emylistsddg at gmail.com
Thu Jul 15 05:08:45 CEST 2010
glad you pointed that out.
struct.unpack or something...i'll look into that module.
> On 14-Jul-10 11:35, eMyListsDDg wrote:
>> the above str is being returned from one key/value pair in a dictionary. it is the addr of a network device.
>> i want to store the addr's in their 8byte mac format like this,
>> [00 11 b2 00 40 2C 4F A4]
>> the combinations of format strings using the print statement hasn't resulted in what i need.
> A few hints:
> Remember that the string is a set of raw binary values, so using ord()
> on each character would give you the numbers you can then have
> str.format() render as hex values.
> You might also find the struct module helpful.
>> looking for a suggestion on how to format this, '\x00\x11\xb2\x00@,O\xa4' into this [00-11-B2-00-40-2C-4F-A4]
>> Best regards,
>> eMyListsDDg mailto:eMyListsDDg at gmail.com
>> Tutor maillist - Tutor at python.org
>> To unsubscribe or change subscription options:
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
eMyListsDDg mailto:eMyListsDDg at gmail.com
More information about the Tutor