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. 关于struts、spring 和 hibernate的说明

    struts 是 web 框架 (jsp/action/actionfrom) hibernate 是 orm框架,处于持久层. spring 是容器框架,用于配置bean,并维护bean之间关系的框 ...

  2. WPF入门教程系列三

    WPF之Binding的使用(一) 一.  前言 初学WPF经常被Binding搞得苦不堪言,Binding的重用性就不做介绍了,在WPF应用程序开发中Binding是一个非常重要的部分.WPF也是近 ...

  3. vmware安装问题:Microsoft Runtime DLL安装程序未能完成安装

    下载vmware station 12 pro后安装,发现有以下问题:   解决方法: 在提示这个页面的时候,在运行中输入: %temp%   在打开来的文件窗口中,找到末尾为 ~setup的文件夹, ...

  4. php的pear包管理

    1.安装:  $ sudo wget http://pear.php.net/go-pear.phar  $ sudo php go-pear.har 2.查看pear下安装的包:  $ pear l ...

  5. Java平台调用.net开发的WebService报错处理

    1.报错:服务器未能识别 HTTP 头 SOAPAction 的值 : 解决办法:.net 开发的WebService文件中(.asmx)增加属性: [SoapDocumentService(Rout ...

  6. 浅谈一致性hash

    相信做过互联网应用的都知道,如何很好的做到横向扩展,其实是个蛮难的话题,缓存可横向扩展,如果采用简单的取模,余数方式的部署,基本是无法做到后期的扩展的,数据迁移及分布都是问题,举个例子: 假设采用取模 ...

  7. iOS 如何缩小打包项目ipa大小

    之前项目上线完全由技术老大搞,这次独立开发自己来,觉得自己的打包项目体积略大,网上搜索了一些比较不错的方法,这里总结下 1.配置编译选项 (Levels选项内)Genetate Debug Symbo ...

  8. 内核交互--procfs

    文档介绍:http://lxr.linux.no/linux+v2.6.37/Documentation/filesystems/proc.txt以下内容抄录linux设备驱动开发详解-宋宝华在/pr ...

  9. LeetCode459. Repeated Substring Pattern

    Description Given a non-empty string check if it can be constructed by taking a substring of it and ...

  10. iOS图片加水印效果的实现并保存至相冊

    图片加水印效果的实现并保存至相冊 实现效果如图: project下载:githubproject下载链接 代码: - (void)viewDidLoad { [super viewDidLoad]; ...