python datetime
2016-02-29 08:22
537 查看
import datetime as DT #convert character string: '20150212 10:12:11' to datetime type: pTime pTime = DT.datetime.strptime('20150212 10:12:11', '%Y%m%d %H:%M:%S') #calculate the number of days between two date:utcnow() and pTime days = ( DT.datetime.utcnow()- pTime ).days #day of the year DOY = ( pTime- DT.datetime(pTime.year, 1, 1) ).days+1 #calculate the time after 1h aftTime = pTime+ DT.timedelta(hours=1)
相关文章推荐
- PythonScript_demo--搭建PXE服务器
- Python中类与对象的关系
- eclipse中配置python以及numpy库
- Python3 urllib 笔记
- python coverage代码覆盖率工具
- python 动态类型
- 转载】在 Mac OS X El Capitan 文件权限问题解决方法 (以安装 IPython 为例)
- python 默认参数问题的陷阱
- Python文件处理
- python连接数据库失败
- Python+Flask微信企业号开发之发送消息
- HOW-TO:Debug Python Scripts with Eclipse
- 仿Openstack的WSGI接口及RESTul服务实现(python)(转)
- python(4) - 装饰器2
- Python解一道题的N种做法(1)
- kaggle的手写识别比赛(python sklearn-KNN)
- python(4) - 装饰器
- python 系统学习笔记(十二)---os os.path os.walk
- 使用python来批量抓取网站图片
- python类