Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. import numpy as np
  2. def hex2bin(hex):
  3. numpy = list(hex)
  4. array = np.array(numpy)
  5. output = np.array([])
  6. for i in range(array.size):
  7. slice = array[i:i+1]
  8. if slice == "0":
  9. result = "0000"
  10. if slice == "1":
  11. result = "0001"
  12. if slice == "2":
  13. result = "0010"
  14. if slice == "3":
  15. result = "0011"
  16. if slice == "4":
  17. result = "0100"
  18. if slice == "5":
  19. result = "0101"
  20. if slice == "6":
  21. result = "0110"
  22. if slice == "7":
  23. result = "0111"
  24. if slice == "8":
  25. result = "1000"
  26. if slice == "9":
  27. result = "1001"
  28. if slice == "A":
  29. result = "1010"
  30. if slice == "B":
  31. result = "1011"
  32. if slice == "C":
  33. result = "1100"
  34. if slice == "D":
  35. result = "1101"
  36. if slice == "E":
  37. result = "1110"
  38. if slice == "F":
  39. result = "1111"
  40. output = np.append(output, list(result))
  41. return output
  42.  
  43. def test(string):
  44. char = list(string)
  45. print(char)
  46. test("test")
  47.  
  48. File "/Users/internone/github/Dynamic-Document/Hex2Bin.py", line 4, in
  49. hex2bin
  50. numpy = list(hex)
  51. TypeError: 'builtin_function_or_method' object is not iterable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement