1. Học hỏi
  2. /
  3. Khoa Học
  4. /
  5. Working with Dates and Times in Python

Connected

Bài tập

Creating datetimes by hand

Often you create datetime objects based on outside data. Sometimes though, you want to create a datetime object from scratch.

You're going to create a few different datetime objects from scratch to get the hang of that process. These come from the bikeshare data set that you'll use throughout the rest of the chapter.

Hướng dẫn 1/3

undefined XP
  • 1
    • Import the datetime class.
    • Create a datetime for October 1, 2017 at 15:26:26.
    • Print the results in ISO format.
  • 2
    • Import the datetime class.
    • Create a datetime for December 31, 2017 at 15:19:13.
    • Print the results in ISO format.
  • 3

    Create a new datetime by replacing the year in dt with 1917 (instead of 2017)