我有两个文件,我在获取新行时没有任何问题,new file
但new_file
与old_file
. 我得到所有的线。我怎样才能得到删除的线?
import difflib
old_file=open(OUTPUT).readlines()
new_file=open(TMP_FILE).readlines()
diff = difflib.unified_diff(old_file, new_file, fromfile='file1', tofile='file2', lineterm='', n=0)
lines = list(diff)[2:]
added = [line[1:] for line in lines if line[0] == '+']
removed = [line[1:] for line in lines if line[0] == '-']
added_users=[]
for line in added:
if line not in removed:
added_users.append(line)