|  | 
 
| 
本帖最后由 算幽幽 于 2019-2-18 21:10 编辑
x
马上注册,结交更多好友,享用更多功能^_^您需要 登录 才可以下载或查看,没有账号?立即注册  
 #当前目录需要crond.txt文件,写入计划表
 #https://github.com/suanyouyou/crond.git
 
 
 复制代码import time
import itchat
def crond():
    cronds=dict()
    n = 0
    with open("crond.txt", 'r', encoding='utf-8') as f:
        #f.readlines是列表
        for line in f.readlines():
        #rstrip去掉右边非字符
            linestr=line.strip()
            linestr=linestr.replace('月','-')
            linestr=linestr.replace('日','')
            cronds[n]={'time':linestr[:11].rstrip(),'content':linestr[11:]}
            n += 1
    return cronds
#print(crond())
# print(time)
#设定一天计时器
daysec=24*60*60
def exec():
    get_time=time.strftime('%m-%d',time.localtime())
    for n in range(len(crond())):
        if get_time[:5]==crond()[n]['time'][:5]:
            contents='时间:%s 任务:%s'%(crond()[n]['time']  ,crond()[n]['content']   )
            itchat.send(contents,'filehelper')
    #开始计时
    time.sleep(daysec)
    exec()
if __name__=="__main__":
    itchat.auto_login(hotReload=True)
    exec()
 | 
 |