#获取昨日的日期

import datetime

now_time = datetime.datetime.now()

yesterday_time = now_time + datetime.timedelta(days=-1)

yesterday_time_nyr = yesterday_time.strftime('%Y%m%d')#格式化输出

……此处省略数据源的读取,直接给出写入文件代码,

将‘新老师’sheet表和‘新同学’sheet表保存到 ‘日报’工作表

df = pd.ExcelWriter('日报'+yesterday_time_nyr+'.xlsx')

teacher.to_excel(bt,'新老师',index=False)

student.to_excel(bt,'新同学',index=False)