#!/usr/local/bin/python3
#AUTHOR:anqixiang
#DATE:2020-01-26
#MODIFY:
#FUNCTION:提取出name2文件有而name1文件没有的部分,并保存到save_file文件中
name1 = '/etc/passwd'
name2 = '/tmp/mima'
save_file = '/tmp/result.txt' #存放结果
def diff():
with open(name1) as f1:
aset = set(f1)
with open(name2) as f2:
bset = set(f2)
with open(save_file, 'w') as f3:
f3.writelines(bset - aset)
print('结果保存在:%s' % save_file)
if __name__ == '__main__':
diff()