github博客传送门
博客园传送门
使用md5删除重复文件思路和本帖一样
首先遍历需要去重文件夹下的所有文件
然后生成每个文件md5码的同时 和集合中的md5码比较
如md5码不存在,则进行保存.如存在,则不进行保存
最后保存路径的文件 则是不重复的文件
import hashlib
import os
from PIL import Image
import numpy as np
files_path = "这里输入你要去重的文件夹路径.."
save_files_path = "这里输入你去重后保存文件的路径..."
files = os.listdir(files_path)
temp = set()
count = 0
for file in files:
file_path = files_path + file
img = Image.open(file_path)
img_array = np.array(img)
md5 = hashlib.md5()
md5.update(img_array)
if md5.hexdigest() not in temp:
temp.add(md5.hexdigest())
img.save(save_files_path + file)
else:
count += 1
print("duplicate removal:", count)
print_r('点个赞吧');
var_dump('点个赞吧');
NSLog(@"点个赞吧!")
System.out.println("点个赞吧!");
console.log("点个赞吧!");
print("点个赞吧!");
printf("点个赞吧!\n");
cout << "点个赞吧!" << endl;
Console.WriteLine("点个赞吧!");
fmt.Println("点个赞吧!")
Response.Write("点个赞吧");
alert(’点个赞吧’)