import difflib
file1 = 'myFile1.txt'
file2 = 'myFile2.txt'
diff = difflib.ndiff(open(file1).readlines(), open(file2).readlines())
print(''.join(diff), end=' ')
Comparing two .txt files using difflib in Python