skip = 2
with open("text.txt") as f:
for line in f:
if line.startswith("blah"):
next(f)
lst = [next(f) for i in range(skip)]
lst = [el.replace('\n', '') for el in lst]
for i in range(len(lst)/2):
lst.insert(i,lst.pop(i) + lst.pop(i))
lst =[int(i,16) for i in lst]
print lst
我得到了:
lst =[int(i,16) for i in lst]
ValueError: invalid literal for int() with base 16: 'ff 55 00 90 00 92 00 ad 00 c6 00 b7 00 8d 00 98 00 87 00 8a 00 98 00 8f 00 ca 01 78 03 54 05 bf'
任何想法如何获得int hex?
答案 0 :(得分:0)
lst =[int(val,16) for line in lst for val in line.split()]
我认为会做你想要的......虽然很难确定