1、安装 requests_toolbelt 模块,引入该模块下的 MultipartEncoder

2、在 请求体 中使用该模块函数,请求头中增加对应参数值

from requests_toolbelt.multipart.encoder import MultipartEncoder
import requests


request_body = MultipartEncoder(
    {
        "language": "中文",
        "name": "大魔王",
        "age": "18",
        "height": 180,
        "weight": 180,
        "photo": ""
    }
)

request_header = {
    "Content-Type": request_body.content_type
}

response_body = requests.post(url, data=request_body, headers=request_header)

 

相关文章:

  • 2021-10-20
  • 2022-12-23
  • 2021-06-30
  • 2022-01-10
  • 2021-10-28
  • 2022-12-23
  • 2021-10-31
猜你喜欢
  • 2022-03-07
  • 2022-12-23
  • 2022-03-06
  • 2022-12-23
  • 2021-04-20
  • 2021-11-05
相关资源
相似解决方案