使用Python请求中的POST表单数据上载Image

使用Python请求中的POST表单数据上载Image,第1张

概述我正在使用微信API … 在这里,我将使用此API将图像上传到wechat的服务器 http://admin.wechat.com/wiki/index.php?title=Transferring_Multimedia_Files url = 'http://file.api.wechat.com/cgi-bin/media/upload?access_token=%s&type=image'% 我正在使用微信API …
在这里,我将使用此API将图像上传到wechat的服务器
http://admin.wechat.com/wiki/index.php?title=Transferring_Multimedia_Files

url = 'http://file.API.wechat.com/cgi-bin/media/upload?access_token=%s&type=image'%access_token    files = {        'file': (filename,open(filepath,'rb'),'Content-Type': 'image/jpeg','Content-Length': l    }    r = requests.post(url,files=files)

我无法发布数据

解决方法 来自wechat API doc:

curl -F [email protected] "http://file.API.wechat.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE"

将上面的命令翻译为python:

import requestsurl = 'http://file.API.wechat.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE'files = {'media': open('test.jpg','rb')}requests.post(url,files=files)
总结

以上是内存溢出为你收集整理的使用Python请求中的POST表单数据上载Image全部内容,希望文章能够帮你解决使用Python请求中的POST表单数据上载Image所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1191006.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存