课程: Level Up: Python

今天就学习课程吧!

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

Schedule a function

Schedule a function

(video game bleeps) - It can be useful to schedule parts of a program to execute at specific times. Just like setting an alarm to wake yourself up in the morning. Your goal for this challenge is to write a Python function which sets an alarm by playing a sound file and printing a message at the specified time. The function should have three inputs, for the time you want to set the alarm to go off, the sound file you want to play, and the message to display. A call to your set alarm function might look like this using the current system time, plus one, to set an alarm for one second into the future. Pause the video now to create your own solution. Then I'll show you how I solved this challenge. (video game bleeps) All right, for my solution, I used two modules from the Python standard library. The sched module, which implements a general purpose event scheduler and the time module, to manipulate the time units, and…

内容