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

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

#! /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)

python学习之——小闹钟(持续完善ing)的更多相关文章

  1. 从0开始的Python学习004小的总结与补充

    没有时间?快速阅读: Python确实是一种十分精彩又强大的语言. Python是程序.脚本或者软件 python helloworld.py运行你的Python help()帮助你的Python 命 ...

  2. Python学习基本小练习

    对于python的10个小练习做下笔记 1.使用while循环输入1 2 3 4 5 6 8 9 10...自己写的代码如下: num1 = 0 while num1 < 10: num1 = ...

  3. C#/.NET/.NET Core学习视频汇总(持续更新ing)

    前言: 之前有很多小伙伴在我的公众号后台留言问有没有C#/.NET/.NET Core这方面相关的视频推荐,我一般都会推荐他们去B站搜索一下.今天刚好有空收集了网上一些比较好的C#/.NET/.NET ...

  4. python学习:利用循环语句完善输入设置

    利用循环语句完善输入设置 使用for循环: 代码1:_user = "alex"_password = "abc123" for i in range(3): ...

  5. Python学习-55 小游戏- 猜大小

    #游戏开始,首先玩家选择大小,选择完成后开始摇骰子(11<=总值<=18为大,3<=总值<=10为小) import random def roll_dice(numbers= ...

  6. 记录Python学习中的几个小问题

    记录Python学习中的几个小问题,和C#\JAVA的习惯都不太一样. 1.Django模板中比较两个值是否相等 错误的做法 <option value="{{group.id}}&q ...

  7. 【Python教程】《零基础入门学习Python》(小甲鱼)

    [Python教程]<零基础入门学习Python>(小甲鱼) 讲解通俗易懂,诙谐. 哈哈哈. https://www.bilibili.com/video/av27789609

  8. 13本热门书籍免费送!(Python、SpingBoot、Entity Framework、Ionic、MySQL、深度学习、小程序开发等)

    七月第一周,网易云社区联合清华大学出版社为大家送出13本数据分析以及移动开发的书籍(Python.SpingBoot.Entity Framework.Ionic.MySQL.深度学习.小程序开发等) ...

  9. Python小练习(持续更新....)

    最近一直在学习python,这些小练习有些是书上的,有些是别人博客上的! # 1.题目1# 给一个字符串,统计其中的数字.字母和其他类型字符的个数:# 比如输入“124mid-=”,输出:数字=3,字 ...

随机推荐

  1. Debian系统常用配置

    每一次安装Linux之后总需要设置一下系统,下面把常用的设置总结一下,方便以后使用: 1.系统安装包选择 每一次找Linux的安装包时,总会纠结一下选哪个好,我在这里总结一下:安装Debian选择对应 ...

  2. asp.net 网站访问变慢

    资料一 单个网站解决方法:   把应用程序池回收时间缩短到300-600分钟,其间回收过程中,需要占用一点CPU资源,没办法,为了稳定性,再把回收时间设为凌晨5点. 多网站解决方法: 视服务器网站的多 ...

  3. web中session与序列化的问题

    最近在写网上商城项目的时候学习了一个关于session的序列化问题,过来总结一下. 众所周知,session是服务器端的一种会话技术,只要session没有关闭,一个会话就会保持.这里先引出一个问题: ...

  4. Js 扩展

    计算字符串的字节长度 String.prototype.len = function () { return this.replace(/[^\x00-\xff]/g, 'xx').length; } ...

  5. DestroyWindow函数注意事项

    最近遇到这样一个问题:将一个窗口句柄以参数的形式传递给一个线程,在线程中使用完之后要将窗口销毁,调用DestroyWindow销毁窗口是返回false,GetLastError的结果为5:拒绝访问,而 ...

  6. day5_常用模块

    本节大纲: 模块介绍 time &datetime模块 random os sys shutil json & picle shelve xml处理 yaml处理 configpars ...

  7. InnoDB: Error number 24 means ‘Too many open files’.--转载

    一.问题的描述 备份程序 执行前滚的时候报错.(-apply-log) InnoDB: Errornumber 24 means 'Too many open files'. InnoDB: Some ...

  8. 37. Binary Tree Zigzag Level Order Traversal && Binary Tree Inorder Traversal

    Binary Tree Zigzag Level Order Traversal Given a binary tree, return the zigzag level order traversa ...

  9. GLSL语言基础

    from http://www.kankanews.com/ICkengine/archives/120870.shtml 变量 GLSL的变量命名方式与C语言类似.变量的名称可以使用字母,数字以及下 ...

  10. PDF表单域(FormField)在HTML显示与提交数据到服务器

    1.Adobe Arobat Pro等可以编辑表单域,只有几种控件: 2.展示PDF,可用PdfObject.js,Chrome自带? @{ViewBag.Title = @ViewBag.aaa;} ...