through the Urlretrieve method
Import OS
#导入os包, the module can be installed with the PIP installl command without the module
From urllib.request import Urlretrieve
#导入urllib模块
Image_url= "Https://bpic.588ku.com/element_pic/00/16/10/21580951c08d0a9.jpg!/fw/208/quality/90/unsharp/true/compress/true"
#设置一个图片的url, whatever.
Os.makedirs ('./img/', exist_ok=true)
#通过os在当前的工作路径下制作一个img目录, you don't have to say that.
Urlretrieve (Image_url, './img/image1.png ')
#通过urllib的urlretrieve方法使得把图片下载保存到指定的目录
Print (' OK ')
#确认是否执行成功
get through the requests method
Import OS
Import requests
#导入os包, the module can be installed with the PIP installl command without the module
From urllib.request import Urlretrieve
#导入urllib模块
Image_url = "https://bpic.588ku.com/element_pic/00/16/10/21580951c08d0a9.jpg!/fw/208/quality/90/unsharp/true/ Compress/true "
#设置一个图片的url, whatever.
R = Requests.get (Image_url, Stream=true)
With open ('./img/image3.png ', ' WB ') as F:
For chunk in R.iter_content (chunk_size=32):
F.write (Chunk)
Print (' OK ')
Python Download Pictures Simple tutorial