只需像这样解析diff的输出(如果需要,将’-‘更改为’+’):
#!/usr/bin/env python# difflib_testimport difflibfile1 = open('/home/saad/Code/test/new_tweets', 'r')file2 = open('/home/saad/PTITVProgs', 'r')diff = difflib.ndiff(file1.readlines(), file2.readlines())delta = ''.join(x[2:] for x in diff if x.startswith('- '))print delta
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)