【发布时间】:2020-05-27 18:38:40
【问题描述】:
我有许多文本文件,每个文件中都有一个长十六进制数字。我想找出每个十六进制数的长度,即 ['FFFF0F'] =6, ['A23000000000000FD'] =17。
我读了文件:
file_to_open = open(myFile , 'r')
filey = file_to_open.readlines()
print(type(filey))
a = hex(int(filey, 16))
print(type(a))
n = len(filey)
print('length = ', n)
我的错误是:
TypeError: int() cannot convert non-string with explicit base
如果我删除基数 16,我会收到错误:
TypeError : int() argument must be a string, a bytes-like object or a number, not 'list'
关于如何读取数字并找出其中包含多少个十六进制数字的任何想法?
【问题讨论】:
-
请分享您的文件的 sn-p
-
['00FF91203225000000000000000000...04A201F201A301A2010000\n']
标签: python hex text-files readlines