Printing dates in a friendly format
Because people may want to see dates in many different formats, Python comes with very flexible functions for turning date objects into strings.
Let's see what event was recorded first in the Florida hurricane data set. In this exercise, you will format the earliest date in the florida_hurricane_dates list in two ways so you can decide which one you want to use: either the ISO standard or the typical US style.
Questo esercizio fa parte del corso
Working with Dates and Times in Python
Istruzioni dell'esercizio
- Assign the earliest date in
florida_hurricane_datestofirst_date. - Print
first_datein the ISO standard. For example, December 1st, 2000 would be "2000-12-01". - Print
first_datein the US style, using.strftime(). For example, December 1st, 2000 would be "12/1/2000".
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Assign the earliest date to first_date
first_date = ____(florida_hurricane_dates)
# Convert to ISO and US formats
iso = "Our earliest hurricane date: " + first_date.____()
us = "Our earliest hurricane date: " + first_date.____("____")
print("ISO: " + iso)
print("US: " + us)