def game():
prize = ['computer', 'mobile', '2000元现金', '大豆油一桶']
import random
random_num = random.choice(range(100))
while True:
try:
num = int(input('请输入一个数字:').strip())
if random_num == num:
print('恭喜您,抽奖成功,抽到了:%s' % random.choice(prize))
break
elif random_num > num:
print('您输入的数字小了,请重新输入!')
else:
print('您输入的数字大了,请重新输入!')
except Exception as e:
print('错误是:%s' % e)
game()
转载于:https://www.cnblogs.com/laosun0204/p/11127709.html