我对编程完全陌生。想用 Python 写这个基本的闹钟,但是浏览器打不开。我认为这可能是我的 if 语句不起作用。那是对的吗?
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)