Skip to content

Instantly share code, notes, and snippets.

@Apkawa
Created November 9, 2012 09:54
Show Gist options
  • Save Apkawa/4044922 to your computer and use it in GitHub Desktop.
Save Apkawa/4044922 to your computer and use it in GitHub Desktop.
binary number to text
>>> import binascii
>>> bin(int(binascii.hexlify('hello'), 16))
'0b110100001100101011011000110110001101111'
>>> n = int('0b110100001100101011011000110110001101111', 2)
>>> binascii.unhexlify('%x' % n)
'hello'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment