Skip to content

Instantly share code, notes, and snippets.

@zhanggang807
Created June 28, 2018 02:37
Show Gist options
  • Save zhanggang807/46e5889e8c089521661d90a71268f12c to your computer and use it in GitHub Desktop.
Save zhanggang807/46e5889e8c089521661d90a71268f12c to your computer and use it in GitHub Desktop.
python 定时信息提醒
import os, sys, time, subprocess
from datetime import datetime
from tkinter import messagebox
if len(sys.argv) == 1:
msg = input('请输入提示要做的事情\n')
t = input('请输入到期时间, 格式:时:分:秒\n')
hms = t.split(':') if ':' in t else t.split(':')
h, m, s = hms
h = 0 if int(h) >= 24 else int(h)
m, s = min(int(m), 59), min(int(s), 59)
now = datetime.now()
nh, nm, ns = now.hour, now.minute, now.second
counter = abs(h - nh) * 60 * 60 + (m - nm) * 60 + (s - ns)
subprocess.Popen(['pythonw', __file__, msg, str(counter)]) //并没有起作用呀
else:
time.sleep(int(sys.argv[2]))
messagebox.showinfo('时间到了!!!', sys.argv[1])
@zhanggang807
Copy link
Author

好像并没有起作用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment