How do I compare files?
Clay Hobbs
clay at lakeserv.net
Wed Jul 23 11:00:32 EDT 2008
On Tue, 2008-07-22 at 17:29 -0700, Matimus wrote:
> On Jul 22, 4:27pm, Clay Hobbs <c... at lakeserv.net> wrote:
> > I am making a program that (with urllib) that downloads two jpeg files
> > and, if they are different, displays the new one. I need to find a way
> > to compare two files in Python. How is this done?
> >
> > -- Ratfink
>
> Do you just want to check to see if they are the same? Or do you
> actually want to know what the differences are?
>
> import urllib
>
> data1 = urllib.urlopen("http://url.of.jpg1").read()
> data2 = urllib.urlopen("http://url.of.jpg2").read()
>
> if data1 == data2:
> print "they are the same"
>
I just wanted to see if they are different. The code I was using that
didn't work was almost the same, except that the lines that download the
files didn't end in .read(). Thank you for your help
-- Ratfink
More information about the Python-list
mailing list