|
20鱼币
- import random
- def lise1():
- '函数功能,生成随机数字列表,通过修改len,以及切片方式,获取随机列表的长度'
- lise2 = []
- while True:
- i = random.randint(1,33)
- if i not in lise2:
- lise2.append(i)
- if len(lise2) == 25:
- return lise2[5:]
- break
-
- xxcs = 500
- lise3 = [2,3,4,10,15,20,25,27,30]
- #不要的双色球号码列表
- while xxcs:
- lise4 = lise1()
- for x in set(lise3):
- while x in lise4[:] : lise4.remove(x)
- lise5 = lise4[3:9]
- lise5.sort()
- print(lise5)
- xxcs = xxcs - 1
复制代码
#还要在加一个功能,随机的500注里,不能有(可设置2,3,4)个以上号码一样。。。。我该如何改进代码呢???
- import random
- def lise1():
- '函数功能,生成随机数字列表,通过修改len,以及切片方式,获取随机列表的长度'
- lise2 = []
- while True:
- i = random.randint(1,10000)
- if i not in lise2:
- lise2.append(i)
- if len(lise2) == 68:
- return lise2[18:48]
- break
-
- xxcs = 500
- lise3 = [1,2,3,4,5,6,7,8,26,27,35,36,44,70,76,78]
- #过滤列表
- z = set()
- while xxcs:
- lise4 = lise1()
- for x in set(lise3):
- while x in lise4[:] : lise4.remove(x)
- lise5 = lise4[8:18]
- lise5.sort()
- c = 0
- for x in z:
- if x in lise5:
- c += 1
- if c > 3:
- break
- else:
- z . update(lise5)
- lise5.sort()
- print(lise5)
- xxcs = xxcs - 1
复制代码
|
|