1、结果展示
run as python lucky.py 1 5 如下,5注释大乐透,5注双色球
2、源码
import sys
import random
def main(argv
):
ttype
= int(argv
[1]) - 1
nums
= int(argv
[2])
listlucky
= [[6,1,33,16],[5,2,35,12]]
for i
in range(nums
):
numlist
= [[],[]]
for j
in range(2):
nums
= listlucky
[ttype
][j
]
nums_max
= listlucky
[ttype
][j
+2]
k
= 1
while(k
<= nums
):
num
= random
.randint
(1,nums_max
)
if num
not in numlist
[j
]:
numlist
[j
].append
(num
)
else:
k
= k
- 1
k
= k
+ 1
for j
in range(2):
numlist
[j
].sort
()
if j
== 0:
numlist
[j
].append
("--")
for x
in numlist
[j
]:
print("%4s,"%x
,end
= '')
print()
if __name__
== "__main__":
main
(sys
.argv
)
转载请注明原文地址:https://tech.qufami.com/read-18481.html