53-集合实例:取出第二个文件有,第一个文件没有的行

# cp /etc/passwd .
# cp /etc/passwd mima
# vim mima  -> 修改,与passwd有些区别

with open('passwd') as fobj:
    aset = set(fobj)

with open('mima') as fobj:
    bset = set(fobj)

with open('diff.txt', 'w') as fobj:
    fobj.writelines(bset - aset)
    原文作者:凯茜的老爸
    原文地址: https://www.jianshu.com/p/1ad92a52be79
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞