[Python]线程池并发

import time
from concurrent.futures import ThreadPoolExecutor


def download_img(url):
    print(f"下载图片:{url}")
    time.sleep(1)
    print(f"下载完成:{url}")


def main():
    executor = ThreadPoolExecutor(5)
    for i in range(10):
        executor.submit(download_img, i)


main()
posted @ 2023-03-31 10:08  LeoShi2020  阅读(29)  评论(0编辑  收藏  举报