Python for Beginners [16 of 44] Demo: Dates | Microsoft Learn
datetime module
-
获得datetime object中的day, month, year, hour, minutes, sec
today = datetime.now() print('Day: ' + str(today.day)) print('Month: ' + str(today.month)) print('Year: ' + str(today.year)) Day: 23 Month: 2 Year: 2023