print datetime.datetime.now().strftime("%Y.%m.%d")
| Directive |
Meaning |
| %a |
Locale’s abbreviated weekday name. 縮寫的星期幾英文名稱。 |
| %A |
Locale’s full weekday name. 完整的星期幾英文名稱。 |
| %b |
Locale’s abbreviated month name. 縮寫的月份英文名稱。 |
| %B |
Locale’s full month name. 完整的月份英文名稱。 |
| %c |
Locale’s appropriate date and time representation. 一個適當的“日期+時間”表示法,我這里的結果是“月/日/年 時:分:秒”。 |
| %d |
Day of the month as a decimal number [01,31]. 現在日。 |
| %H |
Hour (24-hour clock) as a decimal number [00,23]. 現在小時(24小時制)。 |
| %I |
Hour (12-hour clock) as a decimal number [01,12]. 現在小時(12小時制)。 |
| %j |
Day of the year as a decimal number [001,366]. 現在是一年中的第幾天。 |
| %m |
Month as a decimal number [01,12]. 現在月。 |
| %M |
Minute as a decimal number [00,59]. 現在分。 |
| %p |
Locale’s equivalent of either AM or PM. 現在上/下午,用AM/PM表示。僅與%I一塊使用。 |
| %S |
Second as a decimal number [00,61]. 現在秒。 |
| %U |
Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0. 現在是一年中的第幾個星期。從第一個星期日開始算第1個星期,之前算第0個。 |
| %w |
Weekday as a decimal number [0(Sunday),6]. 現在的星期數,星期日算0。 |
| %W |
Week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0. 現在是一年中的第幾個星期。從第一個星期一開始算第1個星期,之前算第0個。 |
| %x |
Locale’s appropriate date representation. 一個適當的“日期”表示法,我這里的結果是“月/日/年”。 |
| %X |
Locale’s appropriate time representation. 一個適當的“時間”表示法,我這里的結果是“時:分:秒”。 |
| %y |
Year without century as a decimal number [00,99]. 現在年(后兩位)。 |
| %Y |
Year with century as a decimal number. 現在年(完整四位)。 |
| %Z |
Time zone name (no characters if no time zone exists). 時區名稱(如果沒有時區則空白)。 |
| %% |
A literal '%' character. 百分號的轉義符。 |
如果看不明白具體長什么樣,可以用本文開頭那條語句來測試。
就醬。
PS:博客園的表格好坑啊!and圖沒有什么用,但是如果不加的話,就給什么亂七八糟的東西打廣告了。

