import os
import hashlib

def get_md5(file):
    file = open(file,'rb')
    md5 = hashlib.md5(file.read())
    file.close()
    md5_values = md5.hexdigest()
    return md5_values

file_path = "G:\lizhi_music"
os.chdir(file_path)
file_list = os.listdir(file_path)
md5_list =[]
for file in file_list:
    md5 = get_md5(file)
    if md5 not in md5_list:
        md5_list.append(md5)
    else:
        os.remove(file)
        print("文件:%s已删除"%file)

相关文章:

  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-11-18
  • 2021-11-17
猜你喜欢
  • 2021-06-03
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案