发布时间:2019-09-24 08:18:55编辑:auto阅读(2456)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import json
def call(body,url):
headers = {}
# 这里有个细节,如果body需要json形式的话,需要做处理
# 可以是data = json.dumps(body)
response = requests.post(url, data = json.dumps(body), headers = headers)
# 也可以直接将data字段换成json字段,2.4.3版本之后支持
# response = requests.post(url, json = body, headers = headers)
# 返回信息
print response.text
# 返回响应头
print response.status_code
return "回调发送成功"
if __name__=="__main__":
url = "http://192.168.0.128:8080/api/register/result"
data = '[{"bugid": "12260", "type": "success", "bugname": "firefox"}, {"bugid": "12261", "type": "success", "bugname": "xulrunner"}, {"bugid": "12262", "type": "failed", "bugname": "xulrunner-devel"}]'
call(data,url)
上一篇: python操作sqlite3小结
下一篇: python函数学习一(跳出函数)
47793
46325
37206
34688
29279
25937
24830
19913
19478
17971
5757°
6374°
5886°
5932°
7033°
5873°
5897°
6403°
6357°
7731°