代码拉取完成,页面将自动刷新
import os
import hashlib
# 计算文件的md5sum
def md5sum(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
# 获取全部文件后缀名
def get_suffix_and_filelist(path):
sfx=[]
fls=[]
for p,ds,fs in os.walk(path):
for f in fs:
fn = os.path.join(p,f)
fls.append(fn)
sf = os.path.splitext(fn)[1]
if sf not in sfx:
sfx.append(sf)
return sfx,fls
# 文件后缀,文件列表
path = "your/pathname/"
suffix,flists = get_suffix_and_filelist(path)
with open(os.path.join(path,"checksumAll.txt"),"w") as fr:
for fl in flists:
if os.path.splitext(fl)[1] in ['.jpg', '.png', '.MOV', '.JPG', '.PNG', '.GIF']:
fn = fl
fmd = md5sum(fl)
print("%s:%s" %(fn,fmd))
fr.write(fn + ":" + fmd + "\n")
else :
print(fl + " not in list")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。