Date
Date
code
from datetime import datetime
now = datetime.now()
print now
print now.year
print now.month
print now.day
Hot Date
Change the string used above so that it uses a / character in between the %02d and
%04d placeholders instead of a - character.
code
rom datetime import datetime
now = datetime.now()
print '%02d/%02d/%04d' % (now.month, now.day, now.year)
1.
Similar to the last exercise, print the current time in the pretty form of
hh:mm:ss.
Change the string that you are printing so that you have a : character in between
the %02d placeholders.
Change the three things that you are printing from month, day, and year to
now.hour, now.minute, and now.second.
code
from datetime import datetime
now = datetime.now()