# # -*- coding: utf-8 -*-
# 思路:获取所有的文件,并且比较他们的md5,若是md5相同,则认为是相同文件,然后输出
import os
import hashlib
def getAllList(root_path,allfile):
file_path_list = os.listdir(root_path)
for file_path_name in file_path_list:
file_path = os.path.join(root_path,file_path_name)
# print(file_path,os.path.dirname(root_path))
if os.path.isdir(file_path) and 'build' not in os.path.dirname(file_path):
getAllList(file_path,allfile)
else :
if 'drawable' in os.path.basename(root_path):
allfile.append(file_path)
return allfile
# 读取文件中的所有内容
def findMd5(files):
md5list = {}
for filepath in files:
if os.path.isdir(filepath):
continue
md5obj = hashlib.md5()
fd = open(filepath, 'rb')
while True:
buff = fd.read(2048)
if not buff:
break
md
python脚本利用md5输出相似的图片
最新推荐文章于 2024-03-11 16:12:06 发布
本文介绍如何使用Python通过MD5哈希值比较图片内容,找出相似的图片。通过计算图片文件的MD5值,可以高效地检测一组图片中是否存在重复或高度相似的图像。
摘要由CSDN通过智能技术生成