财富自由之大乐透双色球彩票随机生成

tech2024-10-10  17

1、结果展示

run as python lucky.py 1 5 如下,5注释大乐透,5注双色球

2、源码

# -*- coding: utf8 -*- import sys import random # argv[1]: 1:double 2:big # argv[2]: how much 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() #print([x for j in range(2) for x in numlist[j]]) if __name__ == "__main__": main(sys.argv)
最新回复(0)