课程: Python Essential Libraries

今天就学习课程吧!

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

Solution: Pendulum

Solution: Pendulum

(upbeat music) - [tutor] All right, so, how did you do? Were you able to get a working solution? Let's take a look at how I chose to solve the challenge. And keep in mind, that what is important here is not whether your code matches mine. What's important is that you realize that there are usually multiple ways of solving a given programming problem. And your solution, if it works, that's great. It doesn't need to be the same as mine. So let's go ahead and open up the challengesolution.py file and go over the code. All right, so of course, I import the Pendulum library. And then my code figures out what today is by using the pendulum today function. And remember, we saw that earlier in the chapter. I then use a custom format string to print out the date. And notice that the format I'm using is the full day name, the month, and then there is this Do token which prints out the suffix for the day number. And that's what…

内容