使用while 进行循环,进行三轮之后,停止。random.sample() 抽样不重复查询数据
import random
name_list = []
for i in range(0,100):
name_list .append('员工{i}')
winnerNum = [30,6,3] //每个中奖人数
count = 0
while count < 3:
choice = input(f'开始抽{3-count}奖...:')
winners = random.sample(name_list ,lottery_levels[count])
print(winners)
for p in winners:
name_list.remove(p) #删除已中奖者
count += 1
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » python 写一个年会抽奖的demo
发表评论 取消回复