课程: Python Essential Libraries

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Creating dates and times

Creating dates and times

- [Instructor] Let's get started by seeing how Pendulum makes it easy to work with datetime objects that are time zone aware by default. So, here in VS Code, I'm going to open up my ExerciseFiles folder on my desktop, and I'm sure you can do something similar in your editor. And once I have the folder open, I'm going to open up the basicdates_start.py file. And you can see that I'm already importing the pendulum module here at the top of the file along with the time and the datetime modules from the standard library, which we will see why in a little bit. So, one of the easiest ways to create a date and time with Pendulum is to just use the datetime class directly like this. So, I'll write dt1, and I'll call the pendulum.datetime function, and I'll give that a date, so I'll use July 28th. And then, we'll just print that out, all right. So, since Pendulum inherits directly from the standard library's datetime class, I…

内容