python datetime模块(1) 时间格式化
2016-08-09 21:16
651 查看
python 使用datetime模块对时间进行格式化。
datetime.strptime()函数可以把一个输入字符串解析成一个datetime对象。
datetime.strftime()函数可以把datetime对象以你想要的格式写出。
例子环境:python3.4 win7 32位
2016/08/09 21:15:00
datetime.strptime()函数可以把一个输入字符串解析成一个datetime对象。
datetime.strftime()函数可以把datetime对象以你想要的格式写出。
例子环境:python3.4 win7 32位
\#datetimeTest.py from datetime import datetime theDate = '2016-08-09' dateObj = datetime.strptime(theDate,'%Y-%m-%d') dateStr = datetime.strftime(dateObj,'%m/%d/%Y') print(dateStr)
2016/08/09 21:15:00
相关文章推荐
- python datetime模块用strftime 格式化时间
- python datetime模块用strftime 格式化时间
- python datetime模块用strftime 格式化时间
- python datetime模块用strftime 格式化时间
- python datetime模块用strftime 格式化时间
- python datetime模块用strftime 格式化时间
- python datetime模块用strftime 格式化时间
- Python:时间模块:time和datetime
- python处理时间--- datetime模块
- Python中time和datetime模块对时间的操作
- Python之日期与时间处理模块(date和datetime)
- python的time和datetime模块 之 时间形式互转
- python datetime模块处理时间
- 详解python时间模块中的datetime模块
- 【python系列】datetime时间格式化
- Python处理时间 time && datetime 模块
- Python之日期与时间处理模块(date和datetime)
- Python3之时间模块time & datetime & calendar
- python的时间处理模块 date time datetime
- Python datetime时间格式化去掉前导0