栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python生成一段日期的学生随机体温表

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python生成一段日期的学生随机体温表

import xlwt
import datetime
import random

stuname = ['时欣妍','张原硕','朱馨淼','李业恒','李浩洋','毛骏赫','刘梦雨','马懿轩','张城铭','周銆函','刘畅','张艾>淇','吴逸博','张宇杰','安淇','马采薇','毛润腾','麻若瑶','聂玉树','李佳萱','张添慕','王炜皓','张瓷炫','张辰睿','张>博文','张梦璐','于夕宸','付宸威','高梓萌','孔梦洁']
s1 = '2022/4/28'
bgdate = datetime.datetime.strptime(s1, "%Y/%m/%d")
s2 = '2022/6/26'
eddate = datetime.datetime.strptime(s2, "%Y/%m/%d")

interval = int((eddate - bgdate).days) + 1

book = xlwt.Workbook(encoding='utf-8')

for i in range(0, interval, 1):
    #建立sheet
    delta = datetime.timedelta(days=1)
    sheet = book.add_sheet(str(bgdate+delta*i)[0:10])
    #建立表头
    sheet.write(0, 0, '姓名')
    sheet.write(0, 1, '体温(早)')
    sheet.write(0, 2, '体温(中)')
    sheet.write(0, 3, '体温(晚)')
    index = 1
    for name in stuname:
        sheet.write(index, 0, name)
        sheet.write(index, 1, format(random.uniform(36.0,36.9), '.1f'))
        sheet.write(index, 2, format(random.uniform(36.0,36.9), '.1f'))
        sheet.write(index, 3, format(random.uniform(36.0,36.9), '.1f'))
        index += 1


#保存表格
book.save(u"学生体温.xls")

~                                                           
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/994518.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号