Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
目前我正在使用 Python 时间模块创建时间戳。我使用此命令创建了一个字符串
timestamp = time.strftime('%l:%M:%S')
但是,这会以 12 小时格式打印格式。有没有办法以 24 小时格式执行此操作,以便显示为 20:52:53 而不是 8:52:53?
谢谢!
尝试
timestamp = time.strftime('%H:%M:%S')
查看此链接以获取有关 Python 时间模块的信息
https://docs.python.org/3/library/time.html#time.strftime