Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def hex2bin(hex):
- numpy = list(hex)
- array = np.array(numpy)
- output = np.array([])
- for i in range(array.size):
- slice = array[i:i+1]
- if slice == "0":
- result = "0000"
- if slice == "1":
- result = "0001"
- if slice == "2":
- result = "0010"
- if slice == "3":
- result = "0011"
- if slice == "4":
- result = "0100"
- if slice == "5":
- result = "0101"
- if slice == "6":
- result = "0110"
- if slice == "7":
- result = "0111"
- if slice == "8":
- result = "1000"
- if slice == "9":
- result = "1001"
- if slice == "A":
- result = "1010"
- if slice == "B":
- result = "1011"
- if slice == "C":
- result = "1100"
- if slice == "D":
- result = "1101"
- if slice == "E":
- result = "1110"
- if slice == "F":
- result = "1111"
- output = np.append(output, list(result))
- return output
- def test(string):
- char = list(string)
- print(char)
- test("test")
- File "/Users/internone/github/Dynamic-Document/Hex2Bin.py", line 4, in
- hex2bin
- numpy = list(hex)
- TypeError: 'builtin_function_or_method' object is not iterable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement