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)
python学习之——小闹钟(持续完善ing)的更多相关文章
- 从0开始的Python学习004小的总结与补充
没有时间?快速阅读: Python确实是一种十分精彩又强大的语言. Python是程序.脚本或者软件 python helloworld.py运行你的Python help()帮助你的Python 命 ...
- Python学习基本小练习
对于python的10个小练习做下笔记 1.使用while循环输入1 2 3 4 5 6 8 9 10...自己写的代码如下: num1 = 0 while num1 < 10: num1 = ...
- C#/.NET/.NET Core学习视频汇总(持续更新ing)
前言: 之前有很多小伙伴在我的公众号后台留言问有没有C#/.NET/.NET Core这方面相关的视频推荐,我一般都会推荐他们去B站搜索一下.今天刚好有空收集了网上一些比较好的C#/.NET/.NET ...
- python学习:利用循环语句完善输入设置
利用循环语句完善输入设置 使用for循环: 代码1:_user = "alex"_password = "abc123" for i in range(3): ...
- Python学习-55 小游戏- 猜大小
#游戏开始,首先玩家选择大小,选择完成后开始摇骰子(11<=总值<=18为大,3<=总值<=10为小) import random def roll_dice(numbers= ...
- 记录Python学习中的几个小问题
记录Python学习中的几个小问题,和C#\JAVA的习惯都不太一样. 1.Django模板中比较两个值是否相等 错误的做法 <option value="{{group.id}}&q ...
- 【Python教程】《零基础入门学习Python》(小甲鱼)
[Python教程]<零基础入门学习Python>(小甲鱼) 讲解通俗易懂,诙谐. 哈哈哈. https://www.bilibili.com/video/av27789609
- 13本热门书籍免费送!(Python、SpingBoot、Entity Framework、Ionic、MySQL、深度学习、小程序开发等)
七月第一周,网易云社区联合清华大学出版社为大家送出13本数据分析以及移动开发的书籍(Python.SpingBoot.Entity Framework.Ionic.MySQL.深度学习.小程序开发等) ...
- Python小练习(持续更新....)
最近一直在学习python,这些小练习有些是书上的,有些是别人博客上的! # 1.题目1# 给一个字符串,统计其中的数字.字母和其他类型字符的个数:# 比如输入“124mid-=”,输出:数字=3,字 ...
随机推荐
- UNICODE与UTF8和GBK之间的关系
http://wenku.baidu.com/link?url=bheGEzfSjEx-QX-ciME5oKooKYE08_NJZ02l2kKFa7kVZJ4t8Ks2uSNByovgP2QL6btq ...
- windows ftp 连接serv_U 管理员
连接工具名称:8uftp 小技巧:活动模式连接
- localStorage兼容ie6/7 用addBehavior 实现
制作过程我就不说了,程序下面会占出来 define(function(){ if('localStorage' in window) return; function Storage(){ this. ...
- win7下IIS错误:"无法访问请求的页面,因为该页的相关配置数据无效"的解决方法(转)
今天新装win7,然后在IIS下布署了一个网站,布署完成后运行,提示如下错误:HTTP 错误 500.19 - Internal Server Error无法访问请求的页面,因为该页的相关配置数据无效 ...
- SQL语句统计每天、每月、每年的 数据
SQL语句统计每天.每月.每年的数据 1.每年select year(ordertime) 年,sum(Total) 销售合计from 订单表group by year(ordertime) 2.每月 ...
- Android Gradle 多Module单独编译一个Module
假如项目中有两个Module,app1和app2.假如我只想对app1 module进行build,则可以: gradle :App1:build build命令可以换成任意gradle命令.
- Java 开发必会的 Linux 命令
作为一个Java开发人员,有些常用的Linux命令必须掌握.即时平时开发过程中不使用Linux(Unix)或者mac系统,也需要熟练掌握Linux命令.因为很多服务器上都是Linux系统.所以,要和服 ...
- eclipse 3.7 配置svn
1.首先需要安装SVN客户端TortoisSVN.地址:http://tortoisesvn.net/ 2.eclipse低版本的需要安装Subversive Revision Graph,地址:ht ...
- [HTML] CSS 语法
CSS 实例 CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明: 选择器通常是您需要改变样式的 HTML 元素. 每条声明由一个属性和一个值组成. 属性(property)是您希望设置的样 ...
- PHP使用feof()函数读文件的方法
这篇文章主要介绍了PHP使用feof()函数读文件的方法,以实例形式对比了正确与错误的用法,阐明了feof()函数的使用技巧,需要的朋友可以参考下 本文实例讲述了PHP使用feof()函数读文件的方法 ...