python 计算两个日期间的小时数
2016-06-08 10:18
549 查看
#!/usr/bin/env python #encoding: utf-8 import datetime def dateDiffInHours(t1, t2): td = t2 - t1 return td.days * 24 + td.seconds/3600 + 1 if __name__ == '__main__': t1 = datetime.datetime(2016, 3, 31, 0) t2 = datetime.datetime(2016, 6, 8, 2) print dateDiffInHours(t1, t2)
相关文章推荐
- Python之最大公约数和最小公倍数
- python3+任务计划实现的人人影视网站自动签到
- Python之中位数
- python & pandas链接mysql数据库
- 利用python进行数据分析-pandas入门2
- python安装ez_setup.py 【windows环境】
- Python while 循环使用实例
- Python数据类型转换
- python中的for循环如何控制步长
- python计算文件的行数和读取指定行的内容
- "Python" + "OpenCV" 环境配置
- python sqlalchemy 写数据
- [转]LIBSVM-3.18在python环境下的使用
- windows安装theano
- machine learning in action 之二 —— k-Nearest Neighbors
- Python入门笔记
- windows下python 安装igraph库报错 Cannot find the C core of igraph on this system using pkg-config.的解决
- python 列表解析
- python 多个迭代器 VS 单个迭代器
- python3.x dict 迭代