赞
踩
import requests import re #import multiprocessing #form multiprocessing.dummy import Pool from multiprocessing.dummy import Pool as ThreadPool def calc_power2(num): return num * num pool = ThreadPool(3) origin_num = [x for x in range(10)] print("the ",origin_num,"\n") result = pool.map(calc_power2,origin_num) print(result)构造一个列表
origin_num = [ x for x in range(10) ]
pool的map方法使用传入两个参数,一个函数名和list
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。