在postman中调试完成后,直接使用生成的代码在IDE中运行发现请求接口不成功。

需要修改为:

import requests

url = "http://10.**.**.**/user/login"

# form-data参数要写成如下格式,注意有None
data = {
    "username": (None, "13*******"),
    "password": (None, "****")
}

# 此种方式发送form-data类型参数时,请求时不要headers,且用files参数
response = requests.request("POST", url, files=data)
print(response.text)

 参考:https://blog.csdn.net/Chihwei_Hsu/article/details/81943008

相关文章:

  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2021-12-07
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-10
  • 2021-08-28
  • 2021-12-21
  • 2021-10-31
  • 2022-03-07
  • 2022-12-23
相关资源
相似解决方案