zoukankan      html  css  js  c++  java
  • python学习之——小闹钟(持续完善ing)

    "啊,坏了,我忘了那啥啥了~~~"

    为了不坏了,动手做一个小闹钟吧,一点点完善的过程一定美好极了,必像等待培育许久的花儿绽放一样,不多说,加油,期待↖(^ω^)↗

    #! /usr/bin/env python
    #coding=utf-8
    #来源:自己想的,提前设定某些大事的时间点,届时弹窗提示
    #题目:小闹钟
    
    import time
    import datetime
    from Tkinter import *
    from tkMessageBox import *
    
    def alarmclock(alarm_hour,alarm_minute,tip_note):
    
        not_executed = 1 
        while(not_executed):
            dt = list(time.localtime())
            #hour、minite均是int类型
            hour = dt[3]
            minute = dt[4]       
            if hour == alarm_hour and minute == alarm_minute:
                #控制台提示
                print "beepbeep"
                #弹窗提示
                showwarning('DIDADIDA',tip_note )
                not_executed = 0      
            else:
                print time.localtime(time.time())
                time.sleep(30)
            
    
    if __name__=='__main__':
        #input & raw_input 有区别,注意
        given_hour = input("ALARM_HOUR:")
        given_minute = input("ALARM_MINUTE:")
        note = raw_input("TIP_NOTE:")
        alarmclock(given_hour,given_minute,note)
        
        

     调整之后

    #! /usr/bin/env python
    #coding=utf-8
    #题目:小闹钟
    
    import time
    import datetime
    from Tkinter import *
    from tkMessageBox import *
    
    #获取系统时间,弹窗提示(提示内容接受提前设定) def alarmclock(alarm_hour,alarm_minute,tip_note): alarmclock_list = [] not_executed = 1 while(not_executed): dt = list(time.localtime()) #hour、minite均是int类型 alarmclock_list.insert(0,dt[3]) alarmclock_list.insert(1,dt[4]) alarmclock_list.insert(2,tip_note) if alarmclock_list[0] == alarm_hour and alarmclock_list[1]== alarm_minute: #控制台提示 print "beepbeep" #弹窗提示 showwarning('DIDADIDA',alarmclock_list[2] ) not_executed = 0 else: #print time.localtime(time.time()) time.sleep(30) #提示输入的闹钟时间 距离 当前时间 的 差值 def equation_time(input_hour,input_min): input_time = list(time.localtime()) input_time[3]= input_hour input_time[4]= input_min input_time=datetime.datetime(input_time[0],input_time[1],input_time[2],input_time[3],input_time[4],input_time[5]) #print input_time now_time = list(time.localtime()) now_time=datetime.datetime(now_time[0],now_time[1],now_time[2],now_time[3],now_time[4],now_time[5]) #print now_time equation_seconds = (input_time - now_time).seconds equation_hour = equation_seconds % 60 equation_min = equation_seconds // 60 #print equation_seconds #print equation_hour #print equation_min print 'equation_time: %d h %d min' %(equation_hour,equation_min) if __name__=='__main__': #input & raw_input 有区别,注意 given_hour = input("ALARM_HOUR:") given_minute = input("ALARM_MINUTE:") note = raw_input("TIP_NOTE:") equation_time(given_hour,given_minute) alarmclock(given_hour,given_minute,note)
  • 相关阅读:
    夜半饮酒
    邀你到成都来
    成都,我的天堂
    真不想松开你的手
    创业,你懂如何求人办事么?
    只要你愿意
    【五月的歌】重振山河
    成都,我爱你
    就算忘了自己也忘不了你
    假如
  • 原文地址:https://www.cnblogs.com/cloverclt/p/5001144.html
Copyright © 2011-2022 走看看