Access the Datetime Object Properties
We have now completely familiar with datetime
objects! This chapter will be an easy one for us, I guess...
Once you have created a dt
object, you can access its properties using the appropriate attributes.
Taak
Swipe to start coding
Access the year
, month
, hour
, and minute
via the attributes.
Oplossing
from datetime import datetime
date = datetime(2022, 12, 28, 23, 55, 59)
print("Year =", date.year)
print("Month =", date.month)
print("Hour =", date.hour)
print("Minute =", date.minute)
Mark tasks as Completed
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 1. Hoofdstuk 6
AVAILABLE TO ULTIMATE ONLY