a_binary_string = "01100001 01100010 01100011"
ascii_string = "".join([chr(int(binary, 2)) for binary in a_binary_string.split(" ")])
# ascii_string = "abc"
a_string = "abc"
a_byte_array = bytearray(a_string, "utf8")
byte_list = []
for byte in a_byte_array:
binary_representation = bin(byte)
byte_list.append(binary_representation)
print(byte_list)
#Output ['0b1100001', '0b1100010', '0b1100011']
message = "Hello World!"
binary = " ".join(format(ord(c), "b") for c in message)
binary_text = binary
normal = "".join(chr(int(c, 2)) for c in binary_text.split(" "))
print(normal,binary)
test_str = "GeeksforGeeks"
# printing original string
print("The original string is : " + str(test_str))
# using join() + ord() + format()
# Converting String to binary
res = ''.join(format(ord(i), '08b') for i in test_str)
# printing result
print("The string after binary conversion : " + str(res))
#out put example 11000001 8bit