Advertisement
lutunovoleg

Untitled

May 22nd, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | Source Code | 0 0
  1. def str_hex_to_int(string: str):
  2.     return int("0x"+str,16)
  3.     # try:
  4.     #     temp = int(str)
  5.     #     return temp
  6.     # except Exception:
  7.     #     match str:
  8.     #         case "a":
  9.     #             return 10
  10.     #         case "b":
  11.     #             return 11
  12.     #         case "c":
  13.     #             return 12
  14.     #         case "d":
  15.     #             return 13
  16.     #         case "e":
  17.     #             return 14
  18.     #         case "f":
  19.     #             return 15
  20.     #         case _:
  21.     #             raise ValueError("wrong data")
  22.  
  23.  
  24. a = []
  25. with open("test.txt", "r") as f:
  26.     lines = f.readlines()
  27.     for i in range(len(lines)):
  28.         a.append(lines[i].split())
  29. b=[]
  30. for i in range(len(a)):
  31.     b.append([str_hex_to_int(a[i][j]) for j in range(len(a[i]))])
  32.  
  33. print(a)
  34. print(b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement