找回密码
 立即注册
搜索
热搜: Excel discuz
查看: 15|回复: 0

[零碎知识点] 拿时间字符串

[复制链接]

503

主题

7万

元宝

79万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
796738
发表于 前天 16:03 | 显示全部楼层 |阅读模式
  1. import time
  2. # 获取当前时间的 struct_time 对象
  3. current_time_struct = time.localtime()
  4. # 格式化为易读字符串
  5. formatted_time = time.strftime("%Y-%m-%d %H:%M:%S", current_time_struct)
  6. formatted_time = time.strftime("%m-%d %H:%M:%S", current_time_struct)
  7. print(formatted_time)
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|五花八门论坛 ( 豫ICP备15031300号-3 )

GMT+8, 2026-1-21 07:31 , Processed in 0.049077 second(s), 19 queries .

本站已稳定运营:

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表