python -- 双色球

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/4/8 0008 17:48
# @Author  : cyx


# _*_ coding:utf-8 _*_
import random
def cyx_yiyi():
    qiu=[]
    while True:
        hong = random.randint(1,33)#产生一个随机红球
        if hong in qiu:
            continue#跳过本次循环
        qiu.append(hong)#把红色号码添加到列表
        if len(qiu)==6:
            break
    qiu.sort()
    lan=random.randint(1,16)#产生一个随机篮球
    s=""
    for i in qiu:
        s=s+"%02d " %i#02d表示是2位数的整数,个数自动补0
    print (" 红球 "+ s+"篮球 "+"%02d" %lan)

# for i in {1,2,3,4,5}:
for i in range(1, 6):
    # print (i)
    cyx_yiyi()

你可能感兴趣的:(python -- 双色球)