Guest User

Untitled

a guest
Dec 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. def hex2binstr(bstr):
  2. t = {
  3. "0" : '0000',
  4. "1" : '0001',
  5. "2" : '0010',
  6. "3" : '0011',
  7. "4" : '0100',
  8. "5" : '0101',
  9. "6" : '0110',
  10. "7" : '0111',
  11. "8" : '1000',
  12. "9" : '1001',
  13. "a" : '1010',
  14. "b" : '1011',
  15. "c" : '1100',
  16. "d" : '1101',
  17. "e" : '1110',
  18. "f" : '1111',
  19. }
  20.  
  21. o = ""
  22. for b in bstr:
  23. o = o + t[b]
  24. return o
  25.  
  26. print(hex2binstr("d4f3"))
  27. print(hex2binstr("caf3"))
Add Comment
Please, Sign In to add comment