最近刚看python的书,还属于小白级程度,晚上没事买了一注双色球,想想每次买彩票也挺费劲的,就突发奇用python实现一个随机选择双色球功能,以后选择也不用痛苦了,运行下程序自己能选择就好了,省着每次绞尽脑汁去想了,说干就干,以下是全部代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import random redqiu = [] lanseqiu = [] r = '' b = '' for i in range(1,34): redqiu.append(i) for x in range(1,17): lanseqiu.append(x) for r in range(6): r = random.choice(redqiu) print 'The red choice is %s:' %r for b in range(1,2): b = random.choice(lanseqiu) print 'The blue choice is %s:' %b |
运行结果:
The red choice is 30
The red choice is 5
The red choice is 8
The red choice is 10
The red choice is 27
The red choice is 31
The blue choice is 12
以上纯属娱乐,对程序运行结果不本站不负任何责任,当然如果你用了这个程序选择出来的号码真中了大奖,我会非常恭喜您。