Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLeo Marco Corpuz
18,975 PointsDatetime question
Lately, I’m not understanding why we’re using dot notation on datetime twice. (Example. datetime.datetime.now()). The answer for the the next challenge (second task) requires using dot notation twice on datetime before adding the strftime method.
2 Answers
diogorferreira
19,363 PointsIt was confusing at first to me too but to make it easier imagine we import datetime as dt
. The module dt (datetime) has a method called datetime and others too such as date, time, timedelta, etc... From there you can call dt.datetime.now()
or many others, here's some examples.
I recommend reading this explanation, explains it much better than I can
import datetime as dt
dt.datetime.now()
dt.timedelta.days
dt.timedelta.seconds
dt.date.strftime()
diogorferreira
19,363 PointsHappy to help!
Leo Marco Corpuz
18,975 PointsLeo Marco Corpuz
18,975 PointsThanks!