【问题标题】:How to make a request with a conversion specifier in Python?如何在 Python 中使用转换说明符发出请求?
【发布时间】:2022-01-15 06:37:50
【问题描述】:

我正在尝试发送如下 URL 编码的查询。但是,由于查询中的 % 和 & 被识别为转换说明符,因此会发生错误。我该如何解决?

import requests

requests.get("8.8.8.8/abc.php?strrh=%3d%81%26%ad%f94%5c%f0%3c%cej%c00%a4%e5x%07%06%92%da&id=%f9&num=1124")

【问题讨论】:

  • 您遇到了什么错误,完全正确

标签: python python-requests conversion-specifier


【解决方案1】:

您应该使用urllib.parse.urlencode() 在 URL 中正确形成查询字符串。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-20
    • 1970-01-01
    • 2017-11-28
    • 1970-01-01
    • 2012-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多