使用windows定时任务运行python脚本

mail_receive_monitor05.py

import zmail
from tkinter import *
import tkinter.messagebox

server = zmail.server('reblue520@163.com', 'reblue.520')
mail = server.get_latest()

new_id = mail['id']

file_read = open('id.txt', 'r')
old_id = file_read.readline()
file_write = open('id.txt', 'w')
file_write.write(str(new_id))
file_write.close()

if old_id != str(new_id):
    main_window = Tk()
    main_window.withdraw()
    tkinter.messagebox.showinfo("你有邮件了", '老铁,你的邮件来了,瞅一眼吧\n,邮件标题:%s' % mail['subject'])

Win10计划任务  -> 控制面板 -> 管理工具 -> 任务计划程序

执行频率

运行程序:D:\python\mooc_uinversity_songtian\python_email\run.bat

添加参数:D:\python\mooc_uinversity_songtian\python_email\run.bat

起始于:D:\python\mooc_uinversity_songtian\python_email\

posted @ 2020-03-13 23:59  reblue520  阅读(430)  评论(0编辑  收藏  举报