【问题标题】:Viewing POST data with Python Requests Module使用 Python 请求模块查看 POST 数据
【发布时间】:2017-05-22 21:16:09
【问题描述】:

我有一个这个示例程序,但目前它不显示帖子数据。

import requests

r = requests.post('https://requestb.in/12p8nqo1',data={'key':'value'})

print(r.text)

。 >>>'好的'


为什么不打印“key:value”?

谢谢

【问题讨论】:

  • 为什么要这样做?
  • 将浏览器指向requestb.in/12p8nqo1 并查看页面源代码。愿启蒙降临。

标签: python post python-requests


【解决方案1】:

要访问请求数据,您必须处理底层 PreparedRequest 对象,如下所示:

import requests

r = requests.post('https://requestb.in/12p8nqo1',data={'key':'value'})
print(r.request.body)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-02
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 1970-01-01
    • 2018-02-08
    相关资源
    最近更新 更多