我正在使用微信API … 在这里,我将使用此API将图像上传到wechat的服务器 http://admin.wechat测试数据/wiki/index.php?title=Transferring_Multimedia_Files
url = 'http://file.api.wechat测试数据/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 media=@test.jpg "http://file.api.wechat测试数据/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE"
将上面的命令翻译为python:
import requests url = 'http://file.api.wechat测试数据/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE' files = {'media': open('test.jpg', 'rb')} requests.post(url, files=files)
查看更多关于使用Python请求中的POST表单数据上载Image的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did171161