0

我有一个用于电子纸框架的 python 脚本。我想将日期从“2019-02-04”改为“04 feb”。我已经调整代码几个小时了,但我无法让它工作。

代码如下所示:

# Calendar strings to be displayed
day_str = time.strftime("%A")
day_number = time.strftime("%d")
month_str = time.strftime("%B") + ' ' + time.strftime("%Y")
month_cal = str(calendar.month(int(time.strftime("%Y")), int(time.strftime("%m"))))
month_cal = month_cal.split("\n",1)[1];
update_moment = time.strftime("%H") + ':' + time.strftime("%M")
4

1 回答 1

1
d = '2019-02-04'
datetime.strptime(d, '%Y-%m-%d').strftime('%d %b')

输出

'04 Feb'
于 2019-02-04T16:23:48.410 回答