python3.4,发送post
来源:互联网 发布:交趾郡 知乎 编辑:程序博客网 时间:2024/06/16 17:16
import ujson
import requests
HOST = 'http://XXXXXX.api-shoulei-ssl.xunlei.com '
def test_set_global_conf():
url = HOST + '/configuration/globalt_cfg'
text = {'config_type': 'global',
'Version-Code': '10973',
'Channel': 'default',
'App-Type': 'android',
'location': 'default',
'group': ['default', 'default'],
'values': {'test': '1111'}
}
text = ujson.dumps(text)
res = requests.post(url=url, data=text, headers = {'Content-Type':'application/json'})
assert(res.status_code == 200)
import requests
HOST = 'http://XXXXXX.api-shoulei-ssl.xunlei.com '
def test_set_global_conf():
url = HOST + '/configuration/globalt_cfg'
text = {'config_type': 'global',
'Version-Code': '10973',
'Channel': 'default',
'App-Type': 'android',
'location': 'default',
'group': ['default', 'default'],
'values': {'test': '1111'}
}
text = ujson.dumps(text)
res = requests.post(url=url, data=text, headers = {'Content-Type':'application/json'})
assert(res.status_code == 200)
总结:
python3.4版本;
使用requests.post,发送post请求,上传的data参数,要转string类型的json,并且在headers里面指定json类型。
text = ujson.dumps(text) #上传的data参数,要转string类型的json
res = requests.post(url=url, data=text, headers = {'Content-Type':'application/json'}) #在headers里面指定json类型
res = requests.post(url=url, data=text, headers = {'Content-Type':'application/json'}) #在headers里面指定json类型
阅读全文
0 0
- python3.4,发送post
- Python3发送post请求,自动记住cookie
- python3.x上post发送json内容的请求
- python3 urllib post json
- python3爬虫post请求
- Python3 post请求
- python3 发送邮件
- Python3.x 发送邮件
- python3发送smtp邮件
- 解决Python3.6,发送POST请求错误提示:POST data should be bytes, an iterable of bytes, or a file object. It canno
- Python3.4 邮件发送(含带中文附件)
- POST方式发送数据
- IWebBrowser2 发送post请求
- HttpWebRequest发送Post数据
- WebClient发送POST请求
- HttpWebRequest发送数据 post
- 发送 POST 数据
- android发送post请求
- 津津的储蓄计划
- codevs 1391 伊吹萃香
- 对mutable的认识
- 136. Single Number
- Java 监听器
- python3.4,发送post
- Linux 内核优化-调大TCP最大连接数
- EasyPOI->模版形式导出Excel(多Sheet)
- 【笔记】如何用共享单车数据来做城市规划
- angular管道讲解 及 实例两三枚
- 笔试面试-String的比较
- [codeforces291E]Tree-String Problem(hash+倍增)
- 判断浮点数是否相等
- C作业10.14/10.15