1. 学习
  2. /
  3. 课程
  4. /
  5. Working with Dates and Times in Python

Connected

练习

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.

说明 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)