python脚本利用md5输出相似的图片

# # -*- 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
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值