2024-06-26 17:07:05 发布
网友
作为c按请求(python2.7)获取一个图像文件,然后用post方法发送到服务器?在
file = requests.get('http://site.com/immage.jpg') requests.post('http://site2.com/, file=somefile')
如何将file转换为somefile?在
file
somefile
使用响应的^{} attribute:
resp = requests.get('http://site.com/immage.jpg') requests.post('http://site2.com/, files=dict(file=resp.content))
我已经将下载的图片发布为multipart-encoded POST,字段名为file。这取决于您要发布到他们期望的字段名的确切应用程序。在
嗯,你留着吧。。。在
with open("somefile.jpg","wb") as f: f.write(file.content)
使用响应的^{} attribute :
我已经将下载的图片发布为multipart-encoded POST,字段名为
file
。这取决于您要发布到他们期望的字段名的确切应用程序。在嗯,你留着吧。。。在
相关问题 更多 >
编程相关推荐