import hashlib def md5sum(filename, blocksize=65536): hash = hashlib.md5() with open(filename, "rb") as f: #必须是rb形式打开的,否则的两次出来的结果不一致 for block in iter(lambda: f.read(blocksize), b""): hash.update(block) return hash.hexdigest()
import hashlib def md5sum(filename, blocksize=65536): hash = hashlib.md5() with open(filename, "rb") as f: #必须是rb形式打开的,否则的两次出来的结果不一致 for block in iter(lambda: f.read(blocksize), b""): hash.update(block) return hash.hexdigest()