这是一个整理重复文件的程序:
import shutil
import os
import filecmp
filepath=“./”
def getfullpaths(files):
fullpathslist=[]
for f in files:
fullpaths=filepath+f
fullpathslist.append(fullpaths)
return fullpathslist
def judgesamelist(fileA,fileB):
if fileA !=fileB:
if filecmp.cmp(fileA,fileB):
os.remove(fileB)
files=os.listdir(filepath)
fullpaths=getfullpaths(fileA)
for fileA in fullpaths:
for fileB in fullpaths:
judgesamefile(fileA,fileB)
呼,终于写完了,不长但是写了好长时间。望各位大佬指导!
可以把程序放在电脑桌面或文件夹上并运行