Tile learns python_md5 to check the consistency of two files

# 写一个函数,参数是两个文件的路径
# 返回的结果是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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324730302&siteId=291194637