一、新建文件并将数字列表写入
file = open('hello.txt','a+',encoding='utf-8')
string_num = [0x12,0x34]
file.write(str(string_num))
file.close()
print(file)
二、打开文件并取出数字
with open ("hello.txt",'r') as file:
string = file.read()
num = list(string.strip('['+']').split(', '))
tab = int(num[0]) + int(num[1])
print(hex(tab))