import time
import datetime
datebg=input("date begin:")
dateed=input("date end:")
# datebg="2018-01-16 16:41"
# dateed="2018-01-17 16:41"
format="%Y-%m-%d %H:%M"
fdatebg=time.strptime(datebg, format)
fdatebg=datetime.datetime(fdatebg.tm_year,fdatebg.tm_mon,fdatebg.tm_mday,fdatebg.tm_hour,fdatebg.tm_min)
fdateed=time.strptime(dateed, format)
fdateed=datetime.datetime(fdateed.tm_year,fdateed.tm_mon,fdateed.tm_mday,fdateed.tm_hour,fdateed.tm_min)
print(fdatebg)
print(fdateed)
delta=fdateed-fdatebg
print(delta)   output:

2018-01-16 16:41:00
2018-01-16 23:41:00
7:00:00

  

python 时间差计算的更多相关文章

  1. windows下安装python科学计算环境,numpy scipy scikit ,matplotlib等

    安装matplotlib: pip install matplotlib 背景: 目的:要用Python下的DBSCAN聚类算法. scikit-learn 是一个基于SciPy和Numpy的开源机器 ...

  2. php比较时间戳与时间差计算函数( 实用)

    PHP时间比较和时间差如何计算 <?php $zero1=date(“y-m-d h:i:s”); $zero2=”-- ::′; echo “zero1的时间为:”.$zero1.”<b ...

  3. Python TF-IDF计算100份文档关键词权重

    上一篇博文中,我们使用结巴分词对文档进行分词处理,但分词所得结果并不是每个词语都是有意义的(即该词对文档的内容贡献少),那么如何来判断词语对文档的重要度呢,这里介绍一种方法:TF-IDF. 一,TF- ...

  4. Python科学计算(二)windows下开发环境搭建(当用pip安装出现Unable to find vcvarsall.bat)

    用于科学计算Python语言真的是amazing! 方法一:直接安装集成好的软件 刚开始使用numpy.scipy这些模块的时候,图个方便直接使用了一个叫做Enthought的软件.Enthought ...

  5. 目前比较流行的Python科学计算发行版

    经常有身边的学友问到用什么Python发行版比较好? 其实目前比较流行的Python科学计算发行版,主要有这么几个: Python(x,y) GUI基于PyQt,曾经是功能最全也是最强大的,而且是Wi ...

  6. jsp页面根据当前时间和定义时间差计算动态倒计时

    jsp页面根据当前时间和定义时间差计算动态倒计时http://www.jb51.net/article/74140.htm    var maxtime =1000*60; //半个小时,按秒计算,自 ...

  7. Python科学计算之Pandas

    Reference: http://mp.weixin.qq.com/s?src=3&timestamp=1474979163&ver=1&signature=wnZn1UtW ...

  8. Python 科学计算-介绍

    Python 科学计算 作者 J.R. Johansson (robert@riken.jp) http://dml.riken.jp/~rob/ 最新版本的 IPython notebook 课程文 ...

  9. Python科学计算库

    Python科学计算库 一.numpy库和matplotlib库的学习 (1)numpy库介绍:科学计算包,支持N维数组运算.处理大型矩阵.成熟的广播函数库.矢量运算.线性代数.傅里叶变换.随机数生成 ...

随机推荐

  1. Ubuntu14.04下Mongodb数据库可视化工具安装部署步骤(图文详解)(博主推荐)

    不多说,直接上干货! 前期博客 Ubuntu14.04下Mongodb(离线安装方式|非apt-get)安装部署步骤(图文详解)(博主推荐) Ubuntu14.04下Mongodb官网安装部署步骤(图 ...

  2. MVC bundle配置文件模板

    bundle文件放在应用根目录,命名为  bundle.config 内容模板 <?xml version="1.0" encoding="utf-8"? ...

  3. HTML5 CSS3面试题

    一.CSS3有哪些新特性? 1. CSS3实现圆角(border-radius),阴影(box-shadow), 2. 对文字加特效(text-shadow.),线性渐变(gradient),旋转(t ...

  4. FrameLsyout

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_ ...

  5. dfs___刷题记录

    poj 1564 给出一个s,n个数,输出所有的能够得到s的方案 #include<cstdio> #include<cstring> #include<iostream ...

  6. Kattis - Speed Limit

    Speed Limit Bill and Ted are taking a road trip. But the odometer in their car is broken, so they do ...

  7. Facebook再次爆出安全漏洞,9000万用户受影响

    今年上半年开始,美国社交媒体Facebook因数据泄露事件和涉嫌操纵选举等问题频繁接受听证会拷问,然而事情却远没有结束.今年9月Facebook再次爆出安全漏洞,导致9000万用户可能受到影响. 根据 ...

  8. HDU1061 - Rightmost Digit

    Given a positive integer N, you should output the most right digit of N^N. Input The input contains ...

  9. CSS的引入方式和样式

    CSS的引入方式和样式 一.样式 行内样式 内接样式 外接样式(1.链接式 2.导入式) <!--行内样式--> <div> <p style="color: ...

  10. ubuntu/wireshark --Lua: Error during loading: [string "/usr/share/wireshark/init.lua"]:45问题解决

    错误如下: 解决方案:修改init.lua 直接运行wireshark的话会报错: Lua: Error during loading:[string "/usr/share/wiresha ...