超时问题

#超时
from requests.exceptions import ConnectionError,ConnectTimeout,RequestException
try:
    r=requests.get('http://www.baidu.com',timeout=0.1)
    print(r.text)
except ConnectTimeout:
    print('timeout')
except ConnectionError:
    print('conerror')
except RequestException as e:
    print(e)

运行结果

HTTPConnectionPool(host='www.baidu.com', port=80): Read timed out. (read timeout=0.1)

 

posted @ 2019-01-18 17:04  Smilevv-45  阅读(149)  评论(0编辑  收藏  举报