Directive Meaning Example Notes
%a Weekday as locale’s abbreviated name.
Sun, Mon, …, Sat (en_US);
So, Mo, …, Sa (de_DE)

(1)
%A Weekday as locale’s full name.
Sunday, Monday, …, Saturday (en_US);
Sonntag, Montag, …, Samstag (de_DE)

(1)
%w Weekday as a decimal number, where 0 is Sunday and 6 is Saturday. 0, 1, …, 6  
%d Day of the month as a zero-padded decimal number. 01, 02, …, 31  
%b Month as locale’s abbreviated name.
Jan, Feb, …, Dec (en_US);
Jan, Feb, …, Dez (de_DE)

(1)
%B Month as locale’s full name.
January, February, …, December (en_US);
Januar, Februar, …, Dezember (de_DE)

(1)
%m Month as a zero-padded decimal number. 01, 02, …, 12  
%y Year without century as a zero-padded decimal number. 00, 01, …, 99  
%Y Year with century as a decimal number. 1970, 1988, 2001, 2013  
%H Hour (24-hour clock) as a zero-padded decimal number. 00, 01, …, 23  
%I Hour (12-hour clock) as a zero-padded decimal number. 01, 02, …, 12  
%p Locale’s equivalent of either AM or PM.
AM, PM (en_US);
am, pm (de_DE)

(1), (2)
%M Minute as a zero-padded decimal number. 00, 01, …, 59  
%S Second as a zero-padded decimal number. 00, 01, …, 59 (3)
%f Microsecond as a decimal number, zero-padded on the left. 000000, 000001, …, 999999 (4)
%z UTC offset in the form +HHMM or -HHMM (empty string if the the object is naive). (empty), +0000, -0400, +1030 (5)
%Z Time zone name (empty string if the object is naive). (empty), UTC, EST, CST  
%j Day of the year as a zero-padded decimal number. 001, 002, …, 366  
%U Week number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. 00, 01, …, 53 (6)
%W Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0. 00, 01, …, 53 (6)
%c Locale’s appropriate date and time representation.
Tue Aug 16 21:30:00 1988 (en_US);
Di 16 Aug 21:30:00 1988 (de_DE)

(1)
%x Locale’s appropriate date representation.
08/16/88 (None);
08/16/1988 (en_US);
16.08.1988 (de_DE)

(1)
%X Locale’s appropriate time representation.
21:30:00 (en_US);
21:30:00 (de_DE)

(1)
%% A literal '%' character. %  

Python: datetime 转换相关推荐

  1. Python时间转换函数:时间转化为时间戳、时间戳转化为时间、当前日期、当前时间、星期几、前面或者后面多少天、年、月、日等

    Python时间转换函数:时间转化为时间戳.时间戳转化为时间.当前日期.当前时间.星期几.前面或者后面多少天.年.月.日等 #Python时间转换函数:时间转化为时间戳.时间戳转化为时间.当前日期.当 ...

  2. python datetime库_python datetime库使用代码详解

    python 如何将字符串转化为datetime.date心总是在最痛时,复苏:爱总是在最深时,落下帷幕. 比较省事的办法是用time模块的strptime方法来解析日期字符串成为时间对象,然后再把年 ...

  3. python 日期格式月份不加前导,Python datetime时间格式化去掉前导0

    Python datetime时间格式化去掉前导0 Python时间格式化的时候,去掉前导0的: dt = datetime.now() print dt.strftime('%-H') #结果是: ...

  4. python datetime 时区_Python datetime 如何处理时区信息

    在 Python 常用日期处理 -- 内置模块 datetime 探讨了 Python 如何使用 datetime, 如果是一个跨时区的应用(Web 应用都是),就不能只存储一个时间而不带时区,如此, ...

  5. 如何使用Python脚本转换数据和命令行

    在如何使用Python脚本转换数据和命令行中,我们将深入探讨如何使用Python脚本和命令行来转换数据. 但是首先,值得提出一个您可能正在思考的问题:" Python如何适合命令行,为什么当 ...

  6. python datetime模块-Python datetime模块使用方法小结

    datetime模块 当前日期 datetime.date.today() datetime.date(2020, 4, 24) 转换元祖 >>> datetime.date.tim ...

  7. python datetime模块安装_Python datetime模块

    一.简介 在 python 中,datetime 是对日期数据进行处理的主要模块.无论何时你需要用 python 处理日期数据,datetime 都能提供所需方法.datetime 是 python ...

  8. python datetime datetime_Python datetime.tzinfo方法代碼示例

    本文整理匯總了Python中datetime.datetime.tzinfo方法的典型用法代碼示例.如果您正苦於以下問題:Python datetime.tzinfo方法的具體用法?Python da ...

  9. 2021-01-07 Python Opencv转换颜色空间 RGB转为HSV

    Python Opencv转换颜色空间 RGB转为HSV 举个例子,通过摄像头把视频中的蓝色区域凸显出来,剩余的颜色均为黑色 import numpy as npcap = cv2.VideoCapt ...

最新文章

  1. js中常用的算法排序
  2. 那些还在外包公司干的程序员们,快醒醒吧!
  3. avaya http文件服务器,avaya 通讯服务器配置
  4. 《HTML5+CSS3网页设计入门必读》——1.7 使用FTP传输文件
  5. 通过 yar 初识RPC
  6. yelee主题修改博客左侧文章目录的按钮字体
  7. 《趣学CCNA——路由与交换》一2.3 网络层协议概述
  8. ASP.NET Core技术研究-全面认识Web服务器Kestrel
  9. 使用Spring和Hibernate进行集成测试有多酷
  10. 高仿114la网址导航源码完整最新版
  11. 假期第7天……想和测试人聊聊这个问题
  12. /var/log/messages Logging not working on Centos 7
  13. 硬件工程师 VS 软件工程师
  14. mac切换网卡|IP
  15. PAT A1119 Pre- and Post-order Traversals ——小楼一夜听春雨,深巷明朝卖杏花
  16. 2048游戏(C语言)
  17. ThreadLocal介绍和源码解析
  18. RAID 磁盘列阵与阵列卡
  19. The Independent JPEG Group‘s JPEG software
  20. VS Code利用GIT对源码进行管理

热门文章

  1. windows10 + Anaconda搭建tensorflow-gpu环境
  2. java程序发送邮件_用java程序发送邮件
  3. python中执行sql语句_Python执行sql语句
  4. java9 jar hell,Java Jar hell运行时异常
  5. 【阿里云课程】图神经网络基础:图的应用、表示与图卷积
  6. 中国电磁线行业供需状况与十四五竞争态势研究报告2022版
  7. 速卖通爆款如何打造,爆款的周期有多久?
  8. 全球及中国虚拟厨房(仅限外卖的餐厅)行业运营模式分析及发展规划建议研究报告2021-2027年版
  9. 华为的研发给我们什么启示?
  10. mysql --创建数据库