123 456 789 ABC DEF GHI いろは ちりぬ わかよ
123 456 789 ABC DEF GHI いろは ちりぬ わかよ
123 456 789 ABC DEF GHI いろは ちりぬ わかよ うゐの
>>> import filecmp >>> filecmp.cmp('a.txt','b.txt') True >>> filecmp.cmp('a.txt','c.txt') False
>>> import difflib >>> lista = open('a.txt').readlines() >>> listc = open('c.txt').readlines() >>> for diff in difflib.unified_diff(lista, listc, fromfile='a.txt', tofile='c.txt') : print(diff) --- a.txt +++ c.txt @@ -7,3 +7,5 @@ いろは ちりぬ わかよ +うゐの + >>>