关于python request请求 header里的 Content-Type不同类型,data如何发送问题记录

简介: requests请求关于类型记录

类型"Content-Type":"application/json",
调用时格式应该是需要json转码
payload = {"activeuseridg":"6677006280"}
payloadjson = json.dumps(payload1)

r = requests.post(url,headers=header,data=payloadjson)

类型'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
直接字符串形式就可以发送
payload = {"activeuseridg":"6677006280"}
r = requests.post(url,headers=header,data=str(payloadjson))

爬虫或接口测试遇见这样的请求,可以参考

目录
相关文章
|
20天前
|
存储 缓存 JavaScript
python实战篇:利用request库打造自己的翻译接口
python实战篇:利用request库打造自己的翻译接口
31 1
python实战篇:利用request库打造自己的翻译接口
|
30天前
|
Python IDE 开发工具
Python类型注解(十)
Python类型注解(十)
34 0
Python类型注解(十)
|
1月前
|
存储 开发框架 JSON
在 Python 中,如何处理 Web 请求和响应?
【2月更文挑战第26天】【2月更文挑战第90篇】在 Python 中,如何处理 Web 请求和响应?
|
1月前
|
存储 程序员 Python
Python变量类型
Python变量类型
15 0
|
1月前
|
Python
【python】—— 内置类型、运算符、表达式、关键字
【python】—— 内置类型、运算符、表达式、关键字
110 1
|
2天前
|
JSON 测试技术 API
Python的Api自动化测试使用HTTP客户端库发送请求
【4月更文挑战第18天】在Python中进行HTTP请求和API自动化测试有多个库可选:1) `requests`是最流行的选择,支持多种请求方法和内置JSON解析;2) `http.client`是标准库的一部分,适合需要低级别控制的用户;3) `urllib`提供URL操作,适用于复杂请求;4) `httpx`拥有类似`requests`的API,提供现代特性和异步支持。根据具体需求选择,如多数情况`requests`已足够。
9 3
|
3天前
|
存储 Python
Python变量类型
Python变量类型
8 0
|
6天前
|
数据挖掘 API 数据安全/隐私保护
python请求模块requests如何添加代理ip
python请求模块requests如何添加代理ip
|
10天前
|
JSON API 数据格式
python的request库如何拿到json的返回值
python的request库如何拿到json的返回值
10 0
|
10天前
|
索引 Python
python 格式化、set类型和class类基础知识练习(上)
python 格式化、set类型和class类基础知识练习
33 0