def TTB(): a = bytearray (text1, "cp1251") b = list(map(int, a)) c = list(map(str, a)) for i in range (len(c)): if (int(len(c)) < 8): c[i] = "0" + str(c[i]) f = ' '.join (c) int_in = int(f, 16) bin_out = bin(int_in)[:2].zfill(len(f.strip())*2) converted = str(bin_out) text1 = input("your text:") c = TTB() print(c) For example, symbol 1 would be 49 and 1001001, and I need 01001001. And more! These are 33 and 110011 and you need 00110011. How to get each character from ASCII to 8 digit 0-255
zfillis the same, and you use it, just in another place. If you need to finish the lines = '1001001'to 8 digits, makes.zfill(8)for it. - insolor