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")
~
python生成一段日期的学生随机体温表
最新推荐文章于 2023-01-09 22:37:52 发布