Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1780745
  • 博文数量: 636
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 3950
  • 用 户 组: 普通用户
  • 注册时间: 2014-08-06 21:58
个人简介

博客是我工作的好帮手,遇到困难就来博客找资料

文章分类

全部博文(636)

文章存档

2024年(5)

2022年(2)

2021年(4)

2020年(40)

2019年(4)

2018年(78)

2017年(213)

2016年(41)

2015年(183)

2014年(66)

我的朋友

分类: 系统运维

2015-04-10 18:29:53


 # coding = utf-8

 

 from datetime import *

 

 ########################## 日期 ##########################

 date_now = date.today()

 print('now:', date_now)

 print('year:', date_now.year)

 print('month:', date_now.month)

 print('day:', date_now.day)

 

 date_tomorrow = date_now.replace(day = date_now.day + 1)

 print('tomorrow:', date_tomorrow)

 

 delta = date_tomorrow - date_now

 print('tomorrow - now:', delta)

 

 ########################## 时间 ##########################

 time_now = time(13, 59, 59)

 print('now time:', time_now)

 print('hour:', time_now.hour)

 print('minute:', time_now.minute)

 print('second:', time_now.second)

 print('next hour time:', time_now.replace(hour = time_now.hour + 1))

 

 ########################## 日期时间 ##########################

 now = datetime.today()

 print('date:', now.date())

 print('time:', now.time())

 

 ########################## 格式化 ##########################

 print(datetime.today().strftime( '%Y-%m-%d %H:%M:%S %f' ) )


阅读(750) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~