python datetime格式化參數

來源:互聯網
上載者:User

坑爹啊,記憶力不行,老是記不住,都用了這麼久了,記在這裡以後來翻。

Directive Meaning Notes
%a Locale’s abbreviated weekdayname.  
%A Locale’s full weekday name.  
%b Locale’s abbreviated monthname.  
%B Locale’s full month name.  
%c Locale’s appropriate date andtime representation.  
%d Day of the month as a decimalnumber [01,31].  
%f Microsecond as a decimalnumber [0,999999], zero-paddedon the left (1)
%H Hour (24-hour clock) as adecimal number [00,23].  
%I Hour (12-hour clock) as adecimal number [01,12].  
%j Day of the year as a decimalnumber [001,366].  
%m Month as a decimal number[01,12].  
%M Minute as a decimal number[00,59].  
%p Locale’s equivalent of eitherAM or PM. (2)
%S Second as a decimal number[00,61]. (3)
%U Week number of the year(Sunday as the first day ofthe week) as a decimal number[00,53]. All days in a newyear preceding the firstSunday are considered to be inweek 0. (4)
%w Weekday as a decimal number[0(Sunday),6].  
%W Week number of the year(Monday as the first day ofthe week) as a decimal number[00,53]. All days in a newyear preceding the firstMonday are considered to be inweek 0. (4)
%x Locale’s appropriate daterepresentation.  
%X Locale’s appropriate timerepresentation.  
%y Year without century as adecimal number [00,99].  
%Y Year with century as a decimalnumber.  
%z UTC offset in the form +HHMMor -HHMM (empty string if thethe object is naive). (5)
%Z Time zone name (empty stringif the object is naive).  
%% A literal '%' character.  

http://docs.python.org/library/datetime.html#strftime-strptime-behavior

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.