Python格式化日期时间的函数
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 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY