import iofrom PIL
import Image
import requests
url_get = '[http://192.168.0.223:8787/xx(隐藏地址)](http://192.168.0.223:port/xx(隐藏地址))' #某个获取验证码接口
hearders={"tag":33}
response = requests.get (url=url_get,params=hearders)
byte_stream = io.BytesIO(response.content) #请求数据转化字节流
roiImg = Image.open(byte_stream)#Image打开二进制流Byte字节流数据
imgByteArr = io.BytesIO() # 创建一个空的Bytes对象
roiImg.save(imgByteArr, format='PNG') # PNG就是图片格式
imgByteArr = imgByteArr.getvalue() #保存的二进制流
with open("./abc.png", "wb") as f:
f.write(imgByteArr)