On Thu, Jan 8, 2015 at 9:32 PM, Crusier <crus...@gmail.com> wrote: > Hi, > > I am comparing two files, and the program has problem comparing two > files. I am currently using Python 3.3 and Window 7. > > Attached is my code: > > import difflib > > old_file = open('0105-up.txt','r') > file_contentsA = old_file.read() > A = file_contentsA.split(",") > print(A) > print() > > > new_file = open('0106-up.txt','r') > file_contentsB = new_file.read() > B = file_contentsB.split(",") > print(B) > print() > > print('\n'.join(difflib.unified_diff(A, B))) > > old_file.close() > new_file.close() > > When the result comes out, I have noticed that some of the numbers are > in both files and the program fails to the difference. Please help.
You need to say a few more things: what is the output that you expect to see? What is the output that you see? The reason to say this is because your problem statement is missing details in the specification. Concretely, you say that you're "comparing two files". That's way too hand-wavy to be technically useful. :P Ideally, the problem should be described well enough that if we just have the spec and the inputs, we should know what the output looks like, even without seeing your code. Your problem isn't described to that level. As a substitute, if you show what you expect to come out, we can probably triangulate. Also, if you can, reduce the size of the input files to something smaller that still shows up the problem. By reducing the problem to a small size, it makes it easier for both you and us to figure out what's going on. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor