How to convert hex into binary in Python

2 Answers

0 votes
s = "1A3"
  
b = bin(int(s, 16)).zfill(8) 

print(b) 



'''
run:

0b110100011

'''

 



answered Feb 15, 2020 by avibootz
0 votes
s = "1A3"
  
b = "{0:08b}".format(int(s, 16)) 

print(b) 



'''
run:

110100011

'''

 



answered Feb 15, 2020 by avibootz

Related questions

1 answer 237 views
1 answer 214 views
214 views asked Mar 26, 2023 by avibootz
1 answer 207 views
1 answer 249 views
1 answer 310 views
2 answers 317 views
...