Solve the problem that the post submission form of the python requests package is different from json, which leads to the parameter passing is null

The requests package is a very useful package in the python language for sending requests. It integrates many http request methods. This article focuses on the post submission form.

Some of the server-side APIs accept form form submissions, and some accept json data submissions. The difference between their python writing is as follows:

form:

header = {
    "Content-Type": "application/x-www-form-urlencoded"
}

requests.post(url , data={"appname": '111'}, headers=header)

json:

header = {
    "Content-Type": "application/json"
}

requests.post(url , data={"appname": '111'}, headers=header)

The main difference between the two lies in the headers.

Guess you like

Origin blog.csdn.net/dqchouyang/article/details/129473692