- 有两个文件:/root/a.log 和 /root/b.log
# - 两个文件中有大量重复内容
# - 取出只有在 b.log 中存在的行
with open("/root/a.log", mode="r") as fr1:
aset = set(fr1.readlines())
with open("/root/b.log", mode="r") as fr2:
bset = set(fr2.readlines())
print(aset)
print(bset)
print(bset - aset) # 取出只有在 b.log 中存在的行
# {'192.168.92.160\n', '192.168.92.163\n', '192.168.92.161\n', '192.168.92.162\n'}
# {'192.168.92.164\n', '192.168.92.163\n', '192.168.92.162\n'}
# {'192.168.92.164\n'}