Python格式化日期时间的函数
2016-03-10 16:20
190 查看
Python格式化日期时间的函数为datetime.datetime.strftime();由字符串转为日期型的函数为:datetime.datetime.strptime(),两个函数都涉及日期时间的格式化字符串,列举如下:
%a | Abbreviated weekday name |
%A | Full weekday name |
%b | Abbreviated month name |
%B | Full month name |
%c | Date and time representation appropriate for locale |
%d | Day of month as decimal number (01 - 31) |
%H | Hour in 24-hour format (00 - 23) |
%I | Hour in 12-hour format (01 - 12) |
%j | Day of year as decimal number (001 - 366) |
%m | Month as decimal number (01 - 12) |
%M | Minute as decimal number (00 - 59) |
%p | Current locale's A.M./P.M. indicator for 12-hour clock |
%S | Second as decimal number (00 - 59) |
%U | Week of year as decimal number, with Sunday as first day of week (00 - 51) |
%w | Weekday as decimal number (0 - 6; Sunday is 0) |
%W | Week of year as decimal number, with Monday as first day of week (00 - 51) |
%x | Date representation for current locale |
%X | Time representation for current locale |
%y | Year without century, as decimal number (00 - 99) |
%Y | Year with century, as decimal number |
%z, %Z | Time-zone name or abbreviation; no characters if time zone is unknown |
%% | Percent sign |
相关文章推荐
- ascii' codec can't encode characters in position 598-599: ordinal not in range(128)解决方案
- python读写excel
- Python实例讲解 -- 获取本地时间日期(日期计算)
- java + spring (jython\python\script) Error:SyntaxError: no viable alternative at character '\n'
- Java调用Python返回乱码问题解决
- python sqlite3 mysql
- 002_第三部分_[函数 / 高阶函数 / 装饰器]
- python——读写excel
- 【Python】《大话设计模式》Python版代码实现
- 【python】gevent学习
- 【Python】Python中的深浅拷贝
- 【python】编程语言入门经典100例--36
- python:解析XML文件后写入EXCEL(一)
- python的日期模块time,datetime
- 深入学习python的yield和generator
- python中的函数参数(上)
- python 学习笔记八之进程和线程 (进阶篇)
- 元类总结
- python环境配置
- 如何用Python输出PPT中的文字信息