Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def str_hex_to_int(string: str):
- return int("0x"+str,16)
- # try:
- # temp = int(str)
- # return temp
- # except Exception:
- # match str:
- # case "a":
- # return 10
- # case "b":
- # return 11
- # case "c":
- # return 12
- # case "d":
- # return 13
- # case "e":
- # return 14
- # case "f":
- # return 15
- # case _:
- # raise ValueError("wrong data")
- a = []
- with open("test.txt", "r") as f:
- lines = f.readlines()
- for i in range(len(lines)):
- a.append(lines[i].split())
- b=[]
- for i in range(len(a)):
- b.append([str_hex_to_int(a[i][j]) for j in range(len(a[i]))])
- print(a)
- print(b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement