python 3 哈希验证文件 验证文件的sha 256
import hashlib
import os
import sys
def sha256(filename, onlyname):
f = open(filename, 'rb')
sh = hashlib.sha256()
sh.update(f.read())
print (sh.hexdigest(),"*",onlyname )
f.close()
return
path = sys.path[0]
print(path)
list1=os.listdir(path)
print(path + list1[4])
for i in range(0,len(list1)):
if (os.path.isfile(path + '\\' + list1[i]) == True ):
sha256(path + '\\' + list1[i], list1[i])
补充:Web开发 , Python ,