You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python如何将元组列表中的Timestamp元素转换为字符串列表

实现方案

可以通过一行代码完成转换,你可以根据需求选择以下任意一种写法:

  • 直接强制类型转换,写法最简单,pandas Timestamp默认的字符串输出格式正好匹配你的需求:
    res = [str(t[0]) for t in your_list]
    
  • 如果需要严格自定义时间输出格式,可使用strftime方法显式指定格式规则:
    res = [t[0].strftime("%Y-%m-%d %H:%M:%S") for t in your_list]
    

内容的提问来源于stack exchange,提问作者MathMan 99

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 00:36:01