我试图在python中仅打印月份和日期,如下所示:
09-December
08-October
我怎么能这样做?
答案 0 :(得分:5)
答案 1 :(得分:2)
from datetime import datetime
dt = datetime.strptime("09/12/16", "%d/%m/%y")
dt.strftime("%d-%B")
答案 2 :(得分:1)
from datetime import date
d = date(2016, 12, 9)
d.strftime("%d - %A")
# 9 - Friday
# month day year
#d.strftime("%A %d %B %Y")