Table of Contents
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 12 09:14:01 2023

@author: Mortis
"""

import multiprocessing as mp
from multiprocessing import Process, Pool
import os, time
import glob
import hashlib

def main_map(i):
    filename = i
    m = hashlib.md5()
    # 讀取檔案內容,計算 MD5 雜湊值
    with open(filename, "rb") as f:
      buf = f.read()
      m.update(buf)
    h = m.hexdigest()
    return h, i

if __name__ == '__main__':

    inputs = glob.glob(r"F:\影像\網站\*.png")

      # 設定處理程序數量
    pool = Pool(4)

      # 運行多處理程序
    pool_outputs = pool.map(main_map, inputs)

      # 輸出執行結果
    print(pool_outputs)

發佈留言