1. 程式人生 > >#r = requests.post(url,json=data)

#r = requests.post(url,json=data)

#上傳json的post請求 r = requests.post(url,data=json,dumps(data))低版本
#r = requests.post(url,json=data)高版本
import requests
import json
url = "https://httpbin.org/post"

data = {"info":{"code":1,"sex":"男","id":1900,"name":"巧吧軟體測試"},
"code":1,
"name":"巧吧軟體測試","sex":"女",
"data":[{"code":1,"sex":"男","id":1900,"name":"巧吧軟體測試"},{"code":1,"sex":"男","id":1900,"name":"巧吧軟體測試"}],
"id":1900}

r = requests.post(url,json=data)
print(r.headers)
print(r.text)