# 每次与前一个数据作对比,回溯算法
path = 'data/text.txt'
data = [i.replace('\n', '')[:4] for i in list(open(path, encoding='utf-8'))]
print(data)
print('data', len(data))
num = 10000035
list1 = [data[0]]
#
for i in data:
del (list1[:-1])
list1.append(i)
if list1[0] == i:
res = f'相同:{i}:{num}'
print(res)
else:
num += 1
res = f'不同:{i}:{num}'
print(res)
网友评论