首页 > 解决方案 > Python DateTime 将日期时间输入列表转换为仅日期格式

问题描述

我正在以这种格式获得一大堆对象:

[datetime.datetime(2020, 3, 5, 13, 59, 45, 624362, tzinfo=<UTC>), ... ]

我希望将此列表中的每个日期转换为如下所示的字符串:

['2020-03-05', ...]

有什么建议么?

标签: pythondatedatetime

解决方案


[dt.date().isoformat() for dt in your_list_of_datetimes]


推荐阅读