import sys
# f1 = ""
# f2 = ""
# f3 = ""
# # 打印命令行参数
# if len(sys.argv) > 4:
# f1 = sys.argv[1]
# f2 = sys.argv[2]
# f3 = sys.argv[3]
unique_lines = set()
with open('/tmp/jitang.txt', 'r') as f1, open('/tmp/jitang2.txt', 'r') as f2:
for line in f2.readlines():
unique_lines.add(line.strip())
for line in f1.readlines():
unique_lines.add(line.strip())
# 输出去重后的行数
print(len(unique_lines))
# 将去重后的行写入新文件
with open('/tmp/final.txt', 'w') as file:
file.write('\n'.join(sorted(list(unique_lines))))
标签:脚本,f1,f2,lines,合并,argv,sys,unique
From: https://www.cnblogs.com/yiwei-jun/p/17380332.html