from multiprocessing import Process, Pool
import os, time
def main_map(x):
result = x *5
return result
if __name__ == ‘__main__':
inputs = [1, 3, 5, 7]
# 設定處理程序數量
pool = Pool(2)
# 運行多處理程序
pool_outputs = pool.map(main_map, inputs)
# 輸出執行結果
print(pool_outputs)
輸出結果
>>> [5, 15, 25, 35]