Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Access the Datetime Object Properties | Organizing Date and Time Data for Analysis and Applications
Organizing Date and Time Data for Analysis and Applications

book
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?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 6
AVAILABLE TO ULTIMATE ONLY
some-alt