I haven't been able to find an answer to the following question: Start with a string, convert it to its binary representation. How do you get back the original string in Python?
Example:
a = 'hi us'
b = ''.join(format(ord(c), '08b') for c in a)
then b = 0110100001101001001000000111010101110011
Now I want to get 'hi us' back in Python 2.x. For example, this website accomplishes the task: http://string-functions.com/binary-string.aspx
I've seen several answers for Java, but haven't had luck implementing to Python. I've also tried b.decode()
, but don't know which encoding I should use in this case.