标签:dig lib def open 使用 digest size nbsp update
def file_md5(path): ‘‘‘ 获取文件的md5 :param path:文件路径 :return: 返回密文 ‘‘‘ import hashlib import os file_md5 = hashlib.md5() size = os.path.getsize(path) with open(path, mode=‘rb‘) as f: while size > 1024: content = f.read(1024) file_md5.update(content) size -= 1024 else: content = f.read(size) file_md5.update(content) size = 0 return file_md5.hexdigest()
标签:dig lib def open 使用 digest size nbsp update
原文地址:https://www.cnblogs.com/shi-py-rengongzhineng/p/11546249.html