This article describes the method of Python using checksum to calculate whether files are the same. Share it for your reference. The details are as follows:
Suppose there are 2 binary files (, ), use checksum to check whether the content is the same
# coding: utf8 # Python2.6.2 import md5 with open('', 'rb') as f: s = (()).hexdigest() with open('', 'rb') as f: ss = (()).hexdigest() print repr(s), len(s) print repr(ss), len(ss)
I hope this article will be helpful to everyone's Python programming.