with open('./passwd') as fobj: aset = set(fobj) print(aset) with open('./mima') as fobj: bset = set(fobj) print(bset) with open('diff.txt', 'w') as fobj: fobj.writelines(aset - bset)
结果输出: