website :http://cn.python-requests.org/zh_CN/latest/
formula 1:params Parameters , If you pass in a dictionary , Auto code as form .— Aiming at get Method
formula 2:data Parameters , If you pass in a dictionary , Auto code as form .— Aiming at post/put Method
formula 3:data Parameters , If a string is passed in , Publish directly in the original format .— Aiming at post/put Method
formula 4:json Parameters , If you pass in a dictionary , The automatic code is json character string .— Aiming at post/put Method
formula 5:json Parameters , If a string is passed in , Add double quotation marks on the basis of the original format and publish it .— Aiming at post/put Method
formula 6:headers Parameters , The dictionary format is passed — For all methods
data=json.dumps(dictPayload) Equate to json=dictPayload
1、 If it is get request , Because it has only one params Parameters , So according to the formula 1 Construction request ok.
2、 If it is post perhaps put request , The formula is :1 see 2 look for 3 structure .
1 see = See the interface document clearly content-type The format of the message body is required . The form format is still json Format ?
2 look for = according to 1 see , Use the format you see to find the formula , The pithy formula is mainly 2、3( or 7), Find the corresponding formula
3 structure = according to 2 look for , Find the formula to construct the request parameters .
It is worth noting that , Note that dictionaries are nested in dictionaries , Nested dictionaries may also be converted into forms !!