binary to string python code example
Example 1: format binary string python
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!)
Example 2: binary to string
let binary = `1010011 1110100 1100001 1100011 1101011
1001111 1110110 1100101 1110010 1100110
1101100 1101111 1110111`;
let outputStr = binary.split(' ')
.map(bin => String.fromCharCode(parseInt(bin, 2)))
.join('');
console.log(outputStr);
Example 3: python binary to string
testing = "Satana Blabbers".encode() # string to bytes
# now bytes to string
print(testing.decode(), testing.decode('utf-8')) # both are same