python(3.5)中的
try:
page = urllib.request.urlopen(url_sum, timeout=10.0)except:print('error')
表示一次http访问请求的时间最多10秒,一旦超过,本次请求中断,但是不进入下一条,而是继续重复请求这一条。上面的代码若超时会出现以下现象:
.
.
.
http://discussions.citrix.com/forum/1346-access-gateway-enterprise-edition/page-31?prune_day=100&topicfilter=all error http://discussions.citrix.com/forum/1346-access-gateway-enterprise-edition/page-32?prune_day=100&topicfilter=all
.
.
.
不会略过任何一条请求!!!!
本文探讨了Python 3.5中使用urllib.request模块进行HTTP请求时如何设置超时时间,并通过示例代码展示了即使遇到超时情况也不跳过当前请求而继续尝试的策略。
2万+

被折叠的 条评论
为什么被折叠?



