import requests from urllib.request import urlretrieve IMAGE_URL = "http://47.104.63.70:5728/oauth2/captcha.jpg" #使用urlretrieve来下载图片 # urlretrieve(IMAGE_URL,'D:\\yunduan_pyzdh\\yzm\\00.jpg') #使用requests直接get import requests r = requests.get(IMAGE_URL) with open('D:\\yunduan_pyzdh\\yzm\\02.jpg', 'wb') as f: f.write(r.content)