Python:日期和时间类型学习
来源:互联网 发布:原油软件手机版 编辑:程序博客网 时间:2024/06/05 23:45
# 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' ) )
- Python:日期和时间类型学习
- Python 日期和时间学习
- Python学习笔记十:日期和时间
- python学习记录--日期和时间
- Python学习--15 日期和时间
- Python学习--15 日期和时间
- Python学习--15 日期和时间
- Python学习--15 日期和时间
- python 时间和日期
- Python 日期和时间
- Python 日期和时间
- Python 日期和时间
- Python日期和时间
- python日期和时间
- Python 日期和时间
- python日期和时间
- python时间和日期
- Python 日期和时间
- Java垃圾回收机制
- Sicily 13914. Train Passengers
- POJ 1008 Maya Calendar [解题报告] Java
- 关于valgrind两篇很好的文章
- 【区间dp】括号序列再战猪猪侠
- Python:日期和时间类型学习
- GCD介绍(一): 基本概念和Dispatch Queue
- 【AC自动机】 ZOJ 3494 BCD Code
- 关于OS X/linux中的回车和换行
- leetcode之Add Two Numbers
- 常见笔试题-Strcat,strcpy,strcmp,Strlen函数原型
- C Primer Plus 练习 7-9
- GCD介绍(二): 多核心的性能
- 第六周项目一深复制体验