python - Python DateTime 将日期时间输入列表转换为仅日期格式
问题描述
我正在以这种格式获得一大堆对象:
[datetime.datetime(2020, 3, 5, 13, 59, 45, 624362, tzinfo=<UTC>), ... ]
我希望将此列表中的每个日期转换为如下所示的字符串:
['2020-03-05', ...]
有什么建议么?
解决方案
[dt.date().isoformat() for dt in your_list_of_datetimes]
推荐阅读
- c++ - 是否可以强制仅通过单例实例化一个类
- python - 尝试从异步外部调用命令
- spring - 使用 Spring 的 WebSocket 配置问题
- java - 我尝试在 vscode 上运行 java。当我编译文件时,终端会渲染它,但它会显示完整路径(附上图片)
- powershell - 对于查找日志和匹配项的每个循环,将其保存在单独的位置
- python - 重新启动程序时,如何防止文本从 tkinter GUI 消失?
- c++ - 为什么我可以声明一个没有 constexpr 的数组?
- reactjs - React js 中的实时数据更新是如何工作的?
- javascript - 如何从赛普拉斯的模块中存根导出的函数?
- javascript - 解析数据和获取特定对象时未定义