04-07 接口请求构造

get query 请求

params_query = {
"key1": "value1",
"key2": "value2"
}

r = requests.get(url, params=params_query)

form 请求

params_form = {
"key1": "value1",
"key2": "value2"
}

r = requests.post(url, data=params_form)

文件上传

files = {
"file": open("file_path", "rb")
}

r = requests.post(url, files=files)

header

headers = {
"user-agent": "agent"
}

r = requests.get(url, headers=headers)

cookie

cookies = {
"cookies": "value"
}

r = requests.get(url, cookies=cookies)

你可能感兴趣的:(接口自测试,http,python,测试工程师,接口测试)