美文网首页
网络图片获取代码

网络图片获取代码

作者: Destiny_0ea2 | 来源:发表于2018-11-03 22:02 被阅读0次

    import requests

    import os

    url="https://p1.ssl.qhimg.com/t015e3351debe4158e3.jpg"

    root="F://picture//"

    path=root+url.split('/')[-1]

    try:

        if not os.path.exists(root):

            os.mkdir(root)

        if not os.path.exists(path):

            r=requests.get(url)

            with open(path,'wb') as f:

                f.write(r.content)

                f.close()

                print("success to save document")

        else:

            print("document has saved")

    except:

        print("spyder wrong")

    相关文章

      网友评论

          本文标题:网络图片获取代码

          本文链接:https://www.haomeiwen.com/subject/soelxqtx.html