binascii.a2b_binary
Ed Swarthout
ed at hwdebug.com
Mon Apr 3 02:46:37 EDT 2006
Why is there no binascii.a2b_binary(bitstr) which returns the binary data
represented by the bit string? Like:
>>> binascii.a2b_binary('0011001100110101')
'35'
perl has pack("B*", "0011001100110101");
What is the python way to do this?
Other fun with strings:
>>> '3333'.decode('hex')
'33'
>>> '3333'.encode('hex')
'33333333'
I easily found the doc for str.decode(), but it appears to only mention
encodings for languages. It took me a while to connect it to hex_codec.
Maybe a more direct link could be added.
Thanks,
-EdS
More information about the Python-list
mailing list