python - 如何使用 strftime 小写月份名称

标签 python c strftime

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/

相关文章:

c++ - gcc 编译无效的 C 代码

c++ - pthread_join() 是否允许调用线程继续执行?

python - 将 unix 时间戳字符串转换为可读日期

python - 如何在 Ubuntu 20.04 上从 C++ 调用 Python 函数

python - 文件作为可选参数

Python 客户端通过 Nextcloud 上的 OAuth2 访问 CalDAV

c++ - Theta 范围和双重比较?

c - 向 stat() 添加几秒的偏移量

awk - 在Mawk中使用strftime函数

Python raw_input() 中的 EOF 错误