135-1821-9792

文件一致性的判断

# 实现一个函数
# 接受参数: 文件1的参数,文件2的参数,默认参数=10240
# 计俩个文件的md5的值
# 返回它们的一致性结果True,False
import os
import hashlib

def enco_func(file):
    md5_obj1 = hashlib.md5()
    with open(file, 'rb') as f:
        md5_obj1.update(f.read())
    res = md5_obj1.hexdigest()
    return res

def func(file1, file2, l_size=10240):
    res1 = enco_func(file1)
    res2 = enco_func(file2)
    if res1 == res2:
        return True
    else:
        return False

f1 = input('f1>>>')  # E:\text1\day29\03时间差.py
f2 = input('f2>>>')  # E:\text1\day29\04文件大小.py
ret1 = os.path.abspath(r'%s' % f1)
ret2 = os.path.abspath(r'%s' % f2)

print(func(ret1, ret2))

网页标题:文件一致性的判断
文章路径:http://kswsj.com/article/jepoeh.html

其他资讯



Copyright © 2009-2022 www.kswsj.com 成都快上网科技有限公司 版权所有 蜀ICP备19037934号