zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python+csv+datetime+pushplus的值班提醒推送2020.12.19

Python csv 19 推送 提醒 datetime 值班 2020.12
2023-06-13 09:13:02 时间

建一个值班表。

#1、读取excel中的内容
#2、匹配当天日期,格式化为/形式。
#3、把匹配到的日期后面内容推送到微信
# -*- coding: utf-8 -*-
import datetime  # 引入time模块
import csv
import pysnooper 
import requests

#@pysnooper.snoop(normalize= True,prefix="主程序")
def main():
    with open('值班2020.12.19.csv', 'r', newline = '\n')as f:
        reader = csv.reader(f)
        for row in reader:
#            print(type(row[0]))
#            print(row[0])
     
            today = datetime.date.today().strftime("%Y/%m/%d") 
#            print (str(today))
            if today == row[0]:
                print (row[0])
                print (row)
                
                #推送消息到微信
                token = 'XXXXXXXXXXXXXXXXXXXX' #在pushplus网站中可以找到
                title= row[0]+'午班'+row[1]+'夜班'+row[2]
                #改成你要的标题内容
                content = '发送成功'
                url = 'http://pushplus.hxtrip.com/send?token='+token+'&title='+title+'&content='+content+'&template=html&topic=0' #0群发测试
                requests.get(url)               
                
                           
main()