'Easiest way to get character into ASCII-number into binary format in Python

I know this question was answered in a huge variety of questions already. Although I read a lot here on stackoverflow I cant find the best way to achieve the following:

I parse through a string and get a list of different substrings. Then I want to parse through each string and replace the characters with their binary representation.

However I dont know how to not lose the leading zeroes. I could use this but I really dont know how to get rid of the binary indicator in front. The goal is to just get a huge array of ones and zeroes

>>> format(14, '#010b')
'0b00001110'


Solution 1:[1]

You can use the function bin(int) and remplace int with the number and you are going to get the bit representation of the number. If you want to remove the "0b" before the bits you can do bin(int)[2:] using container slicing.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nifle CGE