Logic for a file compare
问题 I trying to write a programm for file compare. For example: file1 1 2 3 4 5 file2 1 2 @ 3 4 5 If I do it line by line, I get: 1 == 1; 2 == 2; 3 != @; 4 != 3; 5 != 4; != 5; But, the truth is that the only difference between the files is @. I want get something like this: 1 == 1; 2 == 2; != @; 3 == 3; 4 == 4; 5 == 5; Which is the best way to do it? without using any external application, such as diff, fc, etc. 回答1: Python has a very handy library for comparing sequences called difflib. The