import hashlib
def hash_file(filename):
hl = hashlib.sha1()
with open(filename, 'rb') as file:
buf = 0
while buf != b'':
buf = file.read(1024)
hl.update(buf)
return hl.hexdigest()
hf = hash_file("d:\\data.txt")
print(hf)
'''
run:
e409096be250b204802c86b95ee1250232b7e2e9
'''