Python: datetime 转换
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 转换的更多相关文章
- python datetime 时间日期处理小结
python datetime 时间日期处理小结 转载请注明出处:http://hi.baidu.com/leejun_2005/blog/item/47f340f1a85b5cb3a50f5232. ...
- python datetime.datetime is not JSON serializable
1.主要是python list转换成json时对时间报错:datetime.datetime(2014, 5, 23, 9, 33, 3) is not JSON serializable. 2. ...
- python datetime和unix时间戳之间相互转换
python datetime和unix时间戳之间相互转换 1.代码: import time import datetime # ...
- Python datetime 转 JSON
Python datetime 转 JSON Python 中将 datetime 转换为 JSON 类型,在使用 Django 时遇到的问题. 环境: Python2.7 代码: import js ...
- allow zero datetime=true导致datetime转换失败:MySql.Data.Types.MySqlDateTime”的对象无法转换为类型“System.Nullable`1[System.DateTime]
allow zero datetime=true导致datetime转换失败:MySql.Data.Types.MySqlDateTime”的对象无法转换为类型“System.Nullable`1[S ...
- Django model '__week_day'与python datetime的weekday()
上周出了个bug,按星期几查询数据的时候,发现查到的数据与显示的星期几并不相符,后来发现代码中按星期几查询,有的地方用的是Django QuerySet提供的'__week_day',有的地方用的是p ...
- python datetime笔记
python datetime笔记 http://mint-green.diandian.com/post/2011-09-09/4892024 获取当前时间,并通过字符串输出. 格式为:%Y-%m- ...
- python datetime模块strptime/strptime format常见格式命令_施罗德_新浪博客
python datetime模块strptime/strptime format常见格式命令_施罗德_新浪博客 python datetime模块strptime/strptime form ...
- python如何转换word格式、读取word内容、转成html
# python如何转换word格式.读取word内容.转成html? import docx from win32com import client as wc # 首先将doc转换成docx wo ...
随机推荐
- Perl文件测试操作和stat函数
在shell中通过test命令或者中括号[]可以进行文件测试以及其它类型的测试,例如判断文件是否存在,比较操作是否为真等等.perl作为更强大的文本处理语言,它也有文件测试类表达式,而且和shell的 ...
- VRF在区块链中的应用
最近区块链领域流行了一种"怪病",许多区块链项目或者设计方案都加入了一个叫做VRFs的算法.那么, (1) 什么是VRFs? (2) VRFs在区块链中解决了什么问题? 本文旨在介 ...
- 使用VSCode如何调试C#控制台程序_1
A-环境安装 https://www.microsoft.com/net/download 下载 .NET Core SDK Installer: https://www.microsoft.com/ ...
- mysqldump备份(Windows)
先说下思路,每天凌晨1点备份线上云服务器上的MySQL数据库,将备份的sql文件拷贝下来. 第一步:通过搜索引擎搜索相关可借鉴的文章.搜索关键字"Windows MySQL 备份" ...
- [转]使用jenkins实现持续集成
本文转自:https://www.cnblogs.com/zishengY/p/7170656.html 一.jenkins 介绍 它是一个自动化的周期性的集成测试过程,从检出代码.编译构建.运行测试 ...
- sql server 查询时会锁表吗?
sql server在执行查询语句时会锁表.在锁表期间禁止增删改操作. 如果不想锁表,那就再表名或别名后面加上WITH(NOLOCK) 如下所示:
- webapi接口发布出错 OwinStartupAttribute
解决办法:在 webconfig 中 <appSettings> <add key="owin:AutomaticAppStartup" value=" ...
- 【微服务No.3】AOP组件ASPectCore简单使用
介绍: AspectCore是.NET标准的基于AOP的跨平台框架[github解释].主要支持:对方面拦截器,依赖注入集成,Web应用程序,数据验证等的核心支持. 使用实例: 首先安装dll: In ...
- springMVC_05结果跳转方式
一.总结 总共有四个, 1.设置ModelAndView的值,根据view和视图解析器跳转到指定的页面 2.通过servletapi对象来实现,不需要视图解析器 3.通过springmvc来实现转发和 ...
- 价值1.35亿美元的BUG
价值1.35亿美元的BUG 译者按: 一横值千金啊! 原文: Mariner 1’s $135 million software bug 译者: Fundebug 为了保证可读性,本文采用意译而非直译 ...