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.
您好,以下代码将打印时间和日期,如果是下午 1:00,它将输出 13 小时。我怎样才能让它输出 1:00 并添加它是上午还是下午?
代码:
import datetime from datetime import datetime print datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print(datetime.now().strftime('%Y-%m-%d %I:%M:%S %p'))
将打印:
2013-06-18 09:47:38 PM
查看文档以找到所有指令。