Convert Character to Binary in Python
We can convert a character to binary using the format method in Python.
Conversion
Character -> N-bit
Using format
method, the given character is converted to bits.
Character -> 8-bit
We can specify 8-bit representation by prepending {0:08b}
before the format
method.
Character -> 16-bit
We can specify 16-bit representation by prepending {0:016b}
before the format
method.