05.对比两个文件的异同

比如我需要对比两个csv文件,一个是之后生成的,有一点改变:

import difflib
 
a = open('a.txt', 'U').readlines()
b = open('b.txt', 'U').readlines()
diff = difflib.ndiff(a, b)
 
sys.stdout.writelines(diff)

你可能感兴趣的:(05.对比两个文件的异同)