【问题标题】:How to retry python requests.get without using sessions如何在不使用会话的情况下重试 python requests.get
【发布时间】:2022-01-06 05:22:35
【问题描述】:

我想重试python requests.get()。我知道我们可以通过会话来做到这一点,但在特定情况下,我只需要重试 requests.get() ,所以我想知道怎么做?有没有像 session 一样的参数可以传递?

【问题讨论】:

标签: python session python-requests request retry-logic


【解决方案1】:
import requests

requests.adapters.DEFAULT_RETRIES = 5
r = requests.get('https://example.com/')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-31
    • 1970-01-01
    • 2018-07-03
    • 2011-08-10
    • 1970-01-01
    相关资源
    最近更新 更多