用python做一个简易休息提醒

来源:Udacity《编程基础:Python》课程2

功能:每隔30分钟,打开特定网页来提醒休息

#coding:utf-8
import webbrowser 
import time

total_breaks = 3
break_count = 0

print "\nThis program started on: " + time.ctime()  # time.ctime():current time(sec)
while break_count <= total_breaks: 
    time.sleep(30 * 60# time.sleep():sleep time(sec) ,30 min
    print "\nBreak Time!\t" + time.ctime()
    webbrowser.open("https://cn.udacity.com/course/programming-foundations-with-python--ud036")  # 开网页
    break_count = break_count + 1
posted @ 2017-08-31 23:11  huidan  阅读(282)  评论(0编辑  收藏  举报