【小工具】1.需要对txt存放的测试数据做去重处理
采用集合去重,在新文件里逐行写入,达成目的
old_file = "D:/testdata/memberId.txt" #old
result_file = "D:/testdata/memberId_new.txt" #new
lines_seen = set()
out_file = open(result_file, "w")
f = open(old_file, "r")
for line in f:
if line not in lines_seen:
out_file.write(line)
lines_seen.add(line)
out_file.close()
print("distinct_success")
--不要用肉体的勤奋,去掩盖思考的懒惰--