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 151 views
1 answer 130 views
130 views asked Mar 26, 2023 by avibootz
1 answer 130 views
1 answer 168 views
1 answer 204 views
2 answers 201 views
...