【问题标题】:How to get the dictionary value after post request如何在发布请求后获取字典值
【发布时间】:2022-11-16 13:18:54
【问题描述】:
import request


p = s.post(url, data=post_json_data,
          headers=headers)

posted_response = p.text

print(posted_response["message"])`

if posted_response["message"] == "Job added":
            print("Success")`

我的 posted_response = {"message":"Job added"}

无法获取值 posted_response["message"]。完成发布请求后,是否有任何解决方案可以从字典中获取价值

【问题讨论】:

    标签: python-3.x


    【解决方案1】:

    您应该将posted_response = p.text 更改为posted_response = p.json()。 希望它能有所帮助。 此致。

    【讨论】:

    • 感谢您的支持
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-24
    • 2013-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多