Advertisement
brilliant_moves

MyAlarm.py

Jul 20th, 2015
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # MyAlarm.py
  2. # Python 3.4.3
  3. # Display date & time; display contents of text file at a given time
  4. # Chris Clarke
  5. # 05.07.2015
  6.  
  7. import time
  8. from time import localtime, strftime
  9.  
  10. #filename = 'HappyBirthday.txt'
  11. #filename = 'HappyNewYear.txt'
  12. filename = 'Time.txt' # or create your own message in a text file
  13. h_set = int(input("Alarm: set hour (0-23): "))
  14. m_set = int(input("Now, set minute (0-59): "))
  15. while True:
  16.     local_t = localtime( time.time())
  17.     h=local_t.tm_hour
  18.     m=local_t.tm_min
  19.     s=local_t.tm_sec
  20.     if h==h_set and m==m_set and s==0: break
  21.     print(strftime("%a, %d %B %Y %H:%M:%S", local_t))
  22.     while local_t==localtime( time.time()):
  23.         pass
  24.  
  25. with open(filename) as f:
  26.     for line in f:
  27.         print (line, end='')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement