图片

import urllib.request
import gevent
from gevent import monkey

monkey.patch_all()


def downloader(img_url):
    req = urllib.request.urlopen(img_url)
    img_content = req.read()
    with open(img_name,"wb") as f:
        f.write(img_content)

def main():
    gevent.joinall([
        gevent.spawn(downloader,"1.jpg","http://p1.so.qhmsg.com/sdr/400__/t011e7c9f15315f4a06.jpg"),
        gevent.spawn(downloader,"2.jpg","http://p3.so.qhimgs1.com/sdr/400__/t01252dabcc60b08723.png")
    ])

if __name__ == "__main__":
    main()

你可能感兴趣的:(图片)