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 ...
随机推荐
- Java基础系列--instanceof关键字
原创作品,可以转载,但是请标注出处地址:http://www.cnblogs.com/V1haoge/p/8492158.html instanceof关键字是在Java类中实现equals方法最常使 ...
- 给HTML页面指定元素添加属性,添加父元素
给HTML页面指定元素添加属性,添加父元素 下面拿一个给富文本中所有的图片增加layer弹窗效果. 思路: 给富文本父元素设置属性. 获取父元素里所有的img 此处用到querySelectorA ...
- samba企业级实战应用详解-技术流ken
1.简介 Samba是一套使用SMB(Server Message Block)协议的应用程序, 通过支持这个协议, Samba允许Linux服务器与Windows系统之间进行通信,使跨平台的互访成为 ...
- JavaScript 系列博客(一)
JavaScript 系列博客(一) 前言 本系列博客为记录学习 JavaScript 的学习笔记,会从基础开始慢慢探索 js.今天的学习笔记主要为 js 引入.定义变量以及 JavaScript 中 ...
- [转]使用jenkins实现持续集成
本文转自:https://www.cnblogs.com/zishengY/p/7170656.html 一.jenkins 介绍 它是一个自动化的周期性的集成测试过程,从检出代码.编译构建.运行测试 ...
- HangFire循环作业中作业因执行时间太长未完成新作业开启导致重复数据的问题
解决方法:在执行的任务方法前加上Mutex特性即可,如果作业未完成,新作业开启的话,新作业会放入计划中的作业队列中,直到前面的作业完成. 必须使用Hangfire.Pro.Redis 和 Hangfi ...
- word转PDF,PDF转Image,使用oppenOffice注意事项等
最近在电子合同等项目中需要把word或者pdf转换成image,用到了openOffice把word转换pdf,以及把pdf转换成图片 感谢小伙伴张国清花费了三天时间来实现了此功能.下面我将把具体的步 ...
- 让MySQL查询更加高效——对查询进行重构
在优化有问题的查询时,目标应该是找到一个更优的方法获得实际需要的结果,而不是一定总是要求从MySQL获取一模一样的结果集 一个复杂查询还是多个简单查询 设计查询的时候一定需要考虑的问题就是,是否需要将 ...
- Java编程思想__内部类
1.对象.new语法 类结构 public class Outer { public String oName; class Inner { public String iName; public v ...
- JavaScript主流框架3月趋势总结
原文: What’s New in JavaScript Frameworks-March 2018 译者: Fundebug 为了保证可读性,本文采用意译而非直译.另外,本文版权归原作者所有,翻译仅 ...