python3中post请求 json 数据
post请求
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import requests
import json
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
}
data = json.dumps({"id":1,"me_test":"test","par_test":[{"phone":"555-555-5555","get_test":"0",}]})
def post_url():
url = "http://xxx.xxx.xxx.xxx/"
requests.post(url = url,data=data,headers=headers)
if __name__=="__main__":
post_url()