str = "cde" str_as_byte_array = bytearray(str, "utf8") bytes_arr = [] for byte in str_as_byte_array: binary_representation = bin(byte) bytes_arr.append(binary_representation) print(bytes_arr) # ['0b1100011', '0b1100100', '0b1100101']