Python DateTime 将日期时间的输入列表转换为唯一的日期格式。

问题描述 投票:0回答:1

我得到了一个大的对象列表,格式是这样的。

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

我想把列表中的每个日期转换成这样的字符串。

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

有什么建议吗?

python date datetime
1个回答
3
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.