One - One Code All

Blog Content

python中requests配置超时及重试次数

Python   2011-08-13 11:19:22
import requests
from requests.adapters import HTTPAdapter

s = requests.Session()
s.mount('http://', HTTPAdapter(max_retries=3))
s.mount('https://', HTTPAdapter(max_retries=3))

s.get('http://baidu.com', timeout=1)
postdata = {} 
s.post('http://baidu.com',data=postdata,timeout=1)



上一篇:pandas中Dataframe中小数的保留小数点后两位
下一篇:date.replace用法

The minute you think of giving up, think of the reason why you held on so long.