I'm trying to translate a stream of 0
, 1
to characters,
without using other libraries,
for example 'Hello World':
0100100001000101010011000100110001001111001000000101011101001111010100100100110001000100
I found something like this:
def BinaryToString(binary):
bingen = (binary[i:i+7] for i in range(0, len(binary), 7))
return ''.join(chr(eval('0b'+n)) for n in bingen)
but when I'm trying to translate, this is the answer:
>>> BinaryToString("0100100001000101010011000100110001001111001000000101011101001111010100100100110001000100")
"$\x11)Db<@W'TID\x04"
>>>