python-Requests库如何正确重试?
import requests
from requests.adapters import HTTPAdapter, Retry
session = requests.Session()
retries = Retry(total=3, backoff_factor=1)
session.mount('http://', HTTPAdapter(max_retries=retries))
session.mount('https://', HTTPAdapter(max_retries=retries))
# 接下来使用session发起的所有请求,默认最多会重试3次
session.get('http://httpbin.org/delay/5', timeout=2)
session.get('https://www.kingname.info')
...