python 日期加减与转换为str
2015-10-22 00:00
573 查看
摘要: python 日期加减与转换为str
from datetime import datetime, timedelta
now_time = datetime.now() # datetime.datetime(2015, 10, 22, 16, 56, 51, 924895)
str_now = str(now_time).split('.')[0]
date_last_time = datetime.strptime(last_pull_time,'%Y-%m-%d %H:%M:%S')
datetime转time时间戳:
time.mktime(order[4].timetuple())
>>> import datetime
>>> d1 = datetime.datetime(2005, 2, 16)
>>> d2 = datetime.datetime(2004, 12, 31)
>>> (d1 – d2).days
47
now_time -d2
from datetime import datetime, timedelta
now_time = datetime.now() # datetime.datetime(2015, 10, 22, 16, 56, 51, 924895)
str_now = str(now_time).split('.')[0]
date_last_time = datetime.strptime(last_pull_time,'%Y-%m-%d %H:%M:%S')
datetime转time时间戳:
time.mktime(order[4].timetuple())
>>> import datetime
>>> d1 = datetime.datetime(2005, 2, 16)
>>> d2 = datetime.datetime(2004, 12, 31)
>>> (d1 – d2).days
47
now_time -d2
相关文章推荐
- eclipse python插件安装
- Windows10下安装配置python和django
- 【Python多进程库】一个函数让你设置CPU数和线程数
- Python -- 偏函数
- Python -- 生成器
- python 发送邮件,未完
- Python爬虫----抓取豆瓣电影Top250
- 09python生成文件脚本
- Window 下搭建OSQA系统
- Python -- 装饰器
- windows 装 python ipython
- 3.4 textwrap--格式化文本库(2)
- 64位的win7配置python、pip、numpy、scipy、matplotlib
- Python -- lambda, map, filter
- python文件操作之标准文件/命令行参数
- python staticmethod and classmethod方法
- Python list 操作
- python 实现 九九乘法表【eclipse 编辑器】
- Python的在线编辑环境
- Python -- 闭包