python datetime 时间模块

datetime.now()会得到当前时间,
datetime.datetime(2023, 2, 13, 17, 24, 29, 309381

currentDateAndTime = datetime.now()
print(f'Time: {currentDateAndTime.year}/{currentDateAndTime.month}/{currentDateAndTime.day}')

Time: 2023/2/13

参考:
[1] https://www.freecodecamp.org/chinese/news/how-to-get-the-current-time-in-python-with-datetime
[2] https://www.freecodecamp.org/chinese/news/python-datetime-now-how-to-get-todays-date-and-time/

posted @ 2023-02-13 14:29  xiaoxuxli  阅读(11)  评论(0编辑  收藏  举报