整理下python多线程的方法,持续更新
[title]ThreadPool 线程池方法[/title]
from multiprocessing.dummy import Pool as ThreadPool pool = ThreadPool(10) # 10个线程 results = pool.map(lambda x: x, urls) # urls是任务列表 list,第一个参数是线程函数 # close the pool and wait for the work to finish pool.close() pool.join() # 最后得到的results,为各个线程的返回结果
[title]Thread Class类 方法[/title]
汤不热爬虫项目:先收藏以后学习整理下:https://github.com/dixudx/tumblr-crawler/blob/master/tumblr-photo-video-ripper.py