python binary to string code example

Example 1: binary to string

let binary = `1010011 1110100 1100001 1100011 1101011 
1001111 1110110 1100101 1110010 1100110 
1101100 1101111 1110111`;

let outputStr = binary.split(' ') //Split string in array of binary chars
   .map(bin => String.fromCharCode(parseInt(bin, 2))) //Map every binary char to real char
   .join(''); //Join the array back to a string

console.log(outputStr);

Example 2: 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

Tags:

Misc Example