Dumps (); dumps(); dumps(); dumps(); dumps();

import requests import json headers = { 'Content-Type': 'application/json', ...... } data = {" n ":" TEST logo ", "s" : "TEST logo", "descr" : "this is the demo", "data" : [], "p" : 1, "dataPage" : 0, "icon_lists" : [], "icon_page": 1 } url = 'http://pddwyb.com/' response = requests.post(url=url, data=json.dumps(data), headers=headers) print(response.json())Copy the code

The request. Post method has a json parameter, and when we pass data to the json parameter, the content-Type is automatically set to application/json as follows:

import requests headers = { 'Content-Type': 'application/json', ...... } data = {" n ":" TEST logo ", "s" : "TEST logo", "descr" : "this is the demo", "data" : [], "p" : 1, "dataPage" : 0, "icon_lists" : [], "icon_page": 1 } url = 'http://pddwyb.com/' response = requests.post(url=url, json=data, headers=headers) print(response.json())Copy the code