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,字 ...
随机推荐
- MVC 全局异常处理及禁用显示头
MVC网站的global.asax中的Application_Start方法里,有这样一段代码: public class MvcApplication : System.Web.HttpApplic ...
- MyEclipse Spring 学习总结三 SpringMVC 表单处理
SpringMVC 表单处理的项目结构如下图所示: Student.java 文件 public class Student { private Integer age; private String ...
- IOS开发-封装数据库sqlite3之为何选择FMDB
为什么使用第三方轻量级框架FMDB? FMDB是用于进行数据存储的第三方的框架,它与SQLite与Core Data相比较,存在很多优势. FMDB是面向对象的,它以OC的方式封装了SQLite的C语 ...
- maya,mel,eval,stringarray
mel里,当要eval("client()"),并且要传递stirngarray参数给函数client()时,正确的写法应该是: global proc intermediator ...
- delphi 常用的将窗口置前的函数
function BringWindowToTopEx(hWnd: HWND): Boolean;begin if IsIconic(hWnd) then ShowWindow(hWnd, SW_RE ...
- (转载)SQL Server 2005 如何启用xp_cmdshell组件
原文地址:http://www.cnblogs.com/atree/p/SQL_SERVER_xp_cmdshell.html [错误描述]: SQL Server阻止了对组件‘xp_cmdshell ...
- 1. Longest Palindromic Substring ( 最长回文子串 )
要求: Given a string S, find the longest palindromic substring in S. (从字符串 S 中最长回文子字符串.) 何为回文字符串? A pa ...
- java变量的作用域
1.可分为成员变量和局部变量 两者的作用域不同:局部变量的作用域仅限于定义它的方法,方法外部无法访问,成员变量的作用域在整个类内部都可以访问如果访问权限允许的话,类外部也可以使用 初始值不同:对于成员 ...
- AtomicInteger
原子量和普通变量相比,主要体现在读写的线程安全上.对原子量的写是原子的,由CAS操作保证原子性.对原子量的读可以读到最新值,由volatile关键字来保证可见性. ublic class Atomic ...
- 自定义控件TextView
public class defineTextView extends TextView { Context context; public defineTextView(Context contex ...