jeudi 26 novembre 2015

Very basic alarm clock does not open webbrowser

I'm totally new to programming. Wanted to write this basic alarm clock with Python but the webbrowser just doesn't open. I think it is probably my if statement that doesn't work. Is that correct?

from datetime import datetime
import webbrowser

name = raw_input("What's your name?")
print ("Hello %s! Let me set an alarm for you. Please answer the following questions about when you want to wake up.")%(name)
alarm_h = raw_input("--> Please enter the hour when I should wake you up:")
alarm_m = raw_input("--> Please enter the exact minute of the hour:")
alarm_sound = raw_input("--> Please enter the Youtube-URL of your favorite song:")

now = datetime.today()

print ("It's now %s h : %s m. We'll wake you up at %s h : %s m." %(now.hour,   now.minute, alarm_h, alarm_m))

if now.hour == alarm_h and now.minute == alarm_m:
    webbrowser.open(alarm_sound, new=2)   

Aucun commentaire:

Enregistrer un commentaire