String Question
"Martin v. Löwis"
martin at v.loewis.de
Wed Jun 28 12:38:34 EDT 2006
diffuser78 at gmail.com wrote:
> mac_string = '001485e55503' (This is the mac address of a computer.)
> Since the MAC adddress are hexadecimal, how should I go about it here.
>
> Please help, every help is appreciated. Thanks
I could not quite understand what you are trying to achieve, but
it appears that you want to convert a character strings of hexadecimal
characters into a byte string with the same bytes. I recommend this:
py> import binascii
py> binascii.a2b_hex("001485e55503")
'\x00\x14\x85\xe5U\x03'
Of course, if the string is fixed, you could just as well use the
result string (i.e. '\x00\x14\x85\xe5U\x03') directly.
Regards,
Martin
More information about the Python-list
mailing list