Home > other >  Python implementation alarm clock function
Python implementation alarm clock function

Time:10-11

Today to share with a Python implementation alarm clock function, the result is that when you set a time, such as: ", after the computer time to you to set the time, will automatically open Groove music, play the music you specify, as the program break, you just need to shut down music is ok, I am in win10 Python3.6 run the ha, there may be insufficient place, please advice,

The import sys
The import time
The import subprocess

# realize alarm clock function
Def alert () :
Set_time=input (" set the alarm clock time: ")
Print (f 'alarm clock is set to: {set_time}')
Print (' time is now:)
While True:
T=time. Localtime ()
FMT="M H % : % : % S"
Now=time. Strftime (FMT, t)
Sys. Stdout. Write (now + '\ r')
Sys. Stdout. Flush ()
Time. Sleep (1)

If now [5]==set_time. Rjust (5, '0') :
Print (' wake up ')
Subprocess. Popen ([' start ', 'C:/Users/RCP/Music/play tricks. Mp3'], shell=True)
Break

Def the main () :
Alert ()

If __name__=="__main__" :
The main ()

Learning python distributed crawler - from foundation to combat - fire Yan institute
  • Related