request模块发送json请求
通过requests模块,入参为json,发送请求获取接口返回值。
import requests,json
url_json = 'http://127.0.0.0:8080/bigdata/'
headers = {'Content-Type': 'application/json;charset=UTF-8'}
data_json = {
"head": {"sign":"269f6c001c993b9be3d9a714f4192580","systemSign":"demo","timeStamp":"1560321476989","version":"20181023"},
"body": {"sensitiveData":"4303701626B7FDC21A29BA5A48075B7D" }
}
#print(json.dumps(data_json))
res_json = requests.post(url_json,data=json.dumps(data_json),headers=headers)
print(res_json)
print(res_json.text)
备注:
#json.dumps将字典转换为字符串
#json.loads将字符串转换为字典
人生的旅途,前途很远,也很暗。然而不要怕,不怕的人的面前才有路。