import requests

r = requests.get("http://www.cnblogs.com/yoyoketang/", timeout=1) # 设置超时

print(r.elapsed)

print(r.elapsed.total_seconds())

print(r.elapsed.microseconds)

print(r.elapsed.seconds)

print(r.elapsed.days)

print(r.elapsed.max)

print(r.elapsed.min)

print(r.elapsed.resolution)

  • total_seconds 总时长,单位秒

  • days 以天为单位

  • microseconds (>= 0 and less than 1 second) 获取微秒部分,大于0小于1秒

  • seconds Number of seconds (>= 0 and less than 1 day) 秒,大于0小于1天

  • max = datetime.timedelta(999999999, 86399, 999999) 最大时间

  • min = datetime.timedelta(-999999999) 最小时间

  • resolution = datetime.timedelta(0, 0, 1) 最小时间单位

设置请求timeout超时的更多相关文章

  1. httpclient: 设置请求的超时时间,连接超时时间等

    httpclient: 设置请求的超时时间,连接超时时间等 public static void main(String[] args) throws Exception{ //创建httpclien ...

  2. Python-requests设置请求的超时时间

    使用timeout 参数可以设定等待连接的秒数,如果等待超时,Requests会抛出异常 >>> requests.get('http://github.com', timeout= ...

  3. ASP.NET Core如何设置请求超时时间

    如果一个请求在ASP.NET Core中运行太久,会导致请求超时,目前ASP.NET Core对请求超时的设置比较麻烦,本文列出目前收集到的一些方法,供大家参考. 部署ASP.NET Core到IIS ...

  4. 【转载】Extjs设置Ajax请求的超时时间timeout

    在Extjs中的Ajax请求中,Ext.Ajax.request 默认超时时间是30秒,有时候我们有比较耗时的操作需要设置更长时间,此时我们就需要修改Ext.Ajax.Requset的超时时间为更长, ...

  5. HTTP请求的python实现(urlopen、headers处理、 Cookie处理、设置Timeout超时、 重定向、Proxy的设置)

    python实现HTTP请求的三中方式:urllib2/urllib.httplib/urllib 以及Requests urllib2/urllib实现 urllib2和urllib是python两 ...

  6. go http.Get请求 http.Post请求 http.PostForm请求 Client 超时设置

    http中有Get/Post/PostForm方法 也可以通过http包中设置client 请求配置 ,然后通过client.Do方法实现请求 下demo中功能都实现,其中有详细说明: package ...

  7. jquery ajax请求数据超时设置

    var ajaxTimeoutTest = $.ajax({ url:'', //请求的URL timeout : 1000, //超时时间设置,单位毫秒 type : 'get', //请求方式,g ...

  8. http请求设置setConnectTimeout()方法超时无响应

    相信非常多小伙伴在写 HttpURLConnection中都设置了setConnectTimeout()方法.目的就是在网络不好的情况下超时返回 然而我们设置的setConnectTimeout()并 ...

  9. vue 设置请求超时时间处理

    Vue.http.post('http://114.214.164.77:2222/crptorgraphy',{msg:JSON.stringify(req)},{emulateJSON:true, ...

随机推荐

  1. CEF与JavaScript交互读取电脑信息

    CefSharp中c#和JavaScript交互读取电脑信息 介绍 CEF是由Marshall Greenblatt于2008年创建的基于Google Chromium的BSD许可开源项目.与主要关注 ...

  2. jQuery 如何存储,获取和删除 Cookies

    jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { options = option ...

  3. Codeforces Round #277 (Div. 2)---A. Calculating Function (规律)

    Calculating Function time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. vue 组件1

    注意:vue组件中的data必须为一个函数,要不vue就会停止工作. 构成组件 组件意味着协同工作,通常父子组件会是这样的关系:组件A在它的模板中使用了组件B,他们之间必然需要相互通信:父组件需要给子 ...

  5. redhat5.8下oracle11g启动失败

    # redhat5.8下oracle11g启动失败 ### 日志文件路径-----------------------------tail -f /u01/app/oracle/product/11. ...

  6. 快速上手UIView动画

    UIView动画有两种使用方法 UIView [begin commit]模式 //动画开始标记 [UIView beginAnimations:@"changeframe" co ...

  7. 域名出售(www.shopbao.com)

    www.shopbao.com 前有淘宝,今有商宝. 商宝网站,精彩无限. 因经济原因,忍痛割爱,欲出售该商业域名. 有意者,请联系:18610310405 MAIL: jieisme@163.com

  8. TPM概述

    TPM(Trusted Platform Module)安全芯片,是指符合TPM(可信赖平台模块)标准的安全芯片.标准由TCG(可信赖计算组织,Trusted Computing Group)提出,目 ...

  9. input子系统分析(转)

    转自:http://www.linuxidc.com/Linux/2011-09/43187.htm 作者:作者:YAOZHENGUO2006 Input子系统处理输入事务,任何输入设备的驱动程序都可 ...

  10. Pairs Forming LCM 在a,b中(a,b<=n)(1 ≤ n ≤ 10^14),有多少组(a,b) (a<b)满足lcm(a,b)==n; lcm(a,b)=p1 ^ max(a1,b1) * p2 ^ max(a2,b2) *..........*pn ^ max(an,bn)

    转自:http://www.cnblogs.com/shentr/p/5285407.html http://acm.hust.edu.cn/vjudge/contest/view.action?ci ...