python 进程池pool.map

from multiprocessing import Pool

def double(x):
    print(x**2)
    return x**2
if __name__ ==  '__main__':
    pool = Pool()
    pool.map(double, list(range(11)))
    print(list(map(double,list(range(11)))))

输出

0
1
4
9
25
16
36
49
64
100
81
0
1
4
9
16
25
36
49
64
81
100
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
posted @ 2023-11-04 21:55  ty1539  阅读(96)  评论(0编辑  收藏  举报