赞
踩
- import randomoffices = [[],[],[]] #定义办公室列表names = ["A","B","C","D","E","F","G","H"] #定义老师名单列表 for name in names: index = random.randint(0,2) #产生随机数作为办公室列表索引 offices[index].append(name) #将老师名单添加到相应索引的办公室子列表中num=1 #显示办公室相应分配老师名单 for office in offices: print("第%d办公室人员名单:%s
- "%(num,office),end=" ") num+=1
运行结果如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。