Unpacking a hex value

Paul Rubin phr-n2002a at nightsong.com
Sat May 18 02:02:58 EDT 2002


Matthew Diephouse <fokke_wulf at hotmail.com> writes:
> I have the following perl code, which I'm trying to translate to python:
> 
> my $out = hex( shift(@_) );
> $out = pack("N", $out);

Maybe I don't understand this, but if you're trying to convert a hex string
to a binary string, use:

import binascii
out = binascii.unhexlify(hex_string)



More information about the Python-list mailing list