binary to string python

24

>>> b'a string'.decode('utf-8')
'a string'
x = 10
print(format(x, '#b')) # 0b1010
print(format(x, 'b')) # 1010
x= 0xF
print(format(x, 'b')) # 1111
print(f'{x:b}') # 1111 (If you knew this format, you are Python Ninja!)
ascii_string = "".join([chr(int(binary, 2)) for binary in a_binary_string.split(" ")])

Comments

Submit
0 Comments