Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python &引用;“哈希校验和”;对象支持所需的缓冲区API_Python_Python 3.x - Fatal编程技术网

Python &引用;“哈希校验和”;对象支持所需的缓冲区API

Python &引用;“哈希校验和”;对象支持所需的缓冲区API,python,python-3.x,Python,Python 3.x,我试图计算pycharm中“Disk image”USbImg.E01的散列值 import hashlib try: file = open("F:/USB Try MATCH/USBTRY.E01",'r') except: print("\nFile not found") ad5 = hashlib.md5() ad5.update(file) print("md5: %s" % ad5.hexdigest()) 对象支持所需的缓冲区API 请尝试ad5.update

我试图计算pycharm中“Disk image”USbImg.E01的散列值

import hashlib

try:
    file = open("F:/USB Try MATCH/USBTRY.E01",'r')
except:
    print("\nFile not found")
ad5 = hashlib.md5()
ad5.update(file)
print("md5: %s" % ad5.hexdigest())
对象支持所需的缓冲区API


请尝试
ad5.update(file.read())
请在回答中添加解释
import hashlib
fiename = 'F:/NEWIMG2/ABC.E01'
hashermd5 = hashlib.md5()
with open(fiename,'rb') as open_file:
    content = open_file.read()
    hashermd5.update(content)
print("md5: %s" % hashermd5.hexdigest())