赞
踩
- import random
- #输入一个抽奖池~~~~
- peopledict={}
- while 1:
- try:
- name,num = raw_input("please input name and num,split,").split(",")
- peopledict[num]=name
- except:
- break
- print peopledict
-
- #抽奖结果
- resultdict={}
- #请输入抽奖次数
- try:
- num = int(raw_input("please input num:"))
- except:
- print "input error"
-
- #进行抽奖啦啦啦
- while num>0:
- result = random.choice(peopledict.keys())
- resultdict[result]=peopledict[result]
- #防止一个恶心的人被连续中奖两次!!!
- del peopledict[result]
- num-=1
-
- print resultdict.values()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。