zoukankan      html  css  js  c++  java
  • 双色球

    双色球

    要求

    每注投注号码由6个红色球号码和1个蓝色球号码组成。红色球号码从1--33中选择;蓝色球号码从1--16中选择

    代码

    import random
    
    number =set()
    num = input('请输入要产生多少注:').strip()
    
    if num.isdigit():
        while len(number)!=int(num):
            red_ball = ' '.join(sorted(random.sample([str(i).zfill(2)for i in range(1,34)],6)))
            bule_ball =' ' .join(sorted(random.sample([str(i).zfill(2) for i in range(1, 17)], 1)))
            two_ball = '红球:%s  蓝球:%s
    '%(red_ball,bule_ball)
            number.add(two_ball)
    else:
        print('请输入数字!')
    
    with open('双色球.txt','a+',encoding='utf-8')as fw:
        fw.writelines(number)
    

    代码

    import random
    all_red_ball = [str(i).zfill(2) for i in range(1, 34)]
    all_blue_ball = [str(i).zfill(2) for i in range(1, 17)]
    def gen_seq():
        blue = random.choice(all_blue_ball)
        red = random.sample(all_red_ball,6)
        red = ' '.join(red)
        return '红球:%s 篮球:%s'%(red,blue)
    
    all_seq=set()
    num = int(input('请输入要产生多少条双色球:').strip())
    while len(all_seq) != num:
        res = gen_seq()+'
    '
        all_seq.add(res)
    with open('passwords.txt','w',encoding='utf-8') as fw:
        fw.writelines(all_seq)
    
  • 相关阅读:
    awk中使用shell变量
    awk的getline命令
    awk的逻辑运算符
    python之re模块
    转载:ensemble计划和数据库
    正则表达式的符号
    awk之match函数
    bash脚本之读取数据
    samtools+bcftools 进行SNP calling
    win10 系统上运行tensorflow三层卷积的方式
  • 原文地址:https://www.cnblogs.com/jiangchunsheng/p/13892798.html
Copyright © 2011-2022 走看看