1my_hexdata = "1a"
2
3scale = 16 # equal to hexadecimal
4
5bin(int(my_hexdata, scale))[2:].zfill(len(my_hexdata)*4)
6# By changing the parameter of the zfill function we allow for any length of
7# hexadecimal code, which is more useful when using this code.
1my_hexdata = "1a"
2
3scale = 16 ## equals to hexadecimal
4
5num_of_bits = 8
6
7bin(int(my_hexdata, scale))[2:].zfill(num_of_bits)