Python闹钟不响

2024-04-20 11:29:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着不用Tkinter做一个简单的闹钟。警报运行并开始每秒钟倒计时一次,但当它到达设定的时间,警报应该关闭,它继续运行。我将如何使警报中断,并打开我的网页浏览器播放选定的歌曲在myline在设定的时间?你知道吗

lines = open("Links.txt").read().splitlines()
mylines = random.choice(lines)
print(mylines)  


name = raw_input("Enter your name: ")

print("Hello, " + name)

alarm_hour = input("Enter the hour you want to wake up: ")
alarm_min = input("Enter the min of the hour you want to wake up: ")

print("You want to wake up at: {0:02}:{1:02}").format(alarm_hour, alarm_min)
alarm = Alarm(alarm_hour, alarm_min)
#print (time.strftime())
clock = time.strftime("%H:%M:%S")
while True:
    if clock != alarm:
    print "The time is: " + clock
    clock = time.strftime("%H:%M:%S")
    time.sleep(1)

    if alarm == clock:
    #webbrowser.open(newlist[pick])
        print "Alarm Now"
        webbrowser.open(mylines)
        break

Tags: thetonameinputtime警报openmin