Precautions for Python requests library parameter submission

The difference between dictionary and json string

# python 中的字典格式,是dict类型
{
    
    'a': 'sd'}
如果声明a = {
    
    "a": "sd"},它仍是字典,不过python会默认将双引号换成单引号,最后打印的仍然为{
    
    'a': 'sd'}


# python 中的json字符串,是str类型
{
    
    "a": "sd"}
两者差别在于引号

During the crawling process, some request parameters are json strings, and some are dictionary types. It is necessary to distinguish between json strings and dictionaries.

The json string format, such asInsert picture description here
clicking on the view source,
Insert picture description here
is obviously in the json string format, and the dictionary can be converted to json string using the json.dumps() function
with data=json.dumps({ })

The dictionary format is like
Insert picture description here

Obviously, what you get after clicking the view source can be directly added to the back of the url, and you can directly submit data={} in the form of a dictionary.

Guess you like

Origin blog.csdn.net/a12355556/article/details/115206207