在 strftime %b
是月份名称
>>> '{:%b}'.format(datetime.now())
'Apr'
我可以使用 chinese-hat 修饰符“胡萝卜”将其大写
>>> '{:%^b}'.format(datetime.now())
'APR'
如何将其小写?即获取结果 '{:%b}'.format(dt).lower()
,但使用模板而不是后处理步骤。
最佳答案
只需在 datetime.now()
之后添加 .lower()
即可。据我所知没有其他方法可以做到这一点。
关于python - 如何使用 strftime 小写月份名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36901047/