Python——获取和使用当前时间

例子:

>>> from datetime import datetime
>>> now = datetime.now()
>>> now.strftime("%Y-%m-%d %H:%M")
'2023-01-04 17:00'
>>> now.strftime("%A, %d. %B %Y %I:%M%p")
'Wednesday, 04. January 2023 05:00PM'

参考文章:

  1. Python——获取和使用当前时间

你可能感兴趣的:(编程语言,python,时间)