Answers for "python convert hex to binary"

1

python convert hex to binary

my_hexdata = "1a"

scale = 16 # equal to hexadecimal

bin(int(my_hexdata, scale))[2:].zfill(len(my_hexdata)*4)
# By changing the parameter of the zfill function we allow for any length of
# hexadecimal code, which is more useful when using this code.
Posted by: Guest on April-05-2021
0

hex to binary python3

my_hexdata = "1a"

scale = 16 ## equals to hexadecimal

num_of_bits = 8

bin(int(my_hexdata, scale))[2:].zfill(num_of_bits)
Posted by: Guest on May-08-2020

Python Answers by Framework

Browse Popular Code Answers by Language