# 写一个函数,参数是两个文件的路径
# 返回的结果是T/F
# 判断两个文件的md5值是否相同
import hashlib
def diff_md5(file1,file2):
def chick_md5(file):
md5 = hashlib.md5()
with open(file, ‘rb‘) as f:
while True:
content = f.read(8192)
if content:
md5.update(content)
else:
break
return md5.hexdigest()
return chick_md5(file1) == chick_md5(file2)
2018-4-23
end
原文地址:https://www.cnblogs.com/tielemao/p/8921953.html
时间: 2024-11-07 10:32:41