random range

import random
def make_code(n):
    res=''
    for i in range(n):
        s1=chr(random.randint(65,90))         #包含65,90
        s2=str(random.randint(0,9))
        res+=random.choice([s1,s2])    #选一个
    return res
print(make_code(4))
red_list=[]
for i in range(1,32):       #包含1,不包含32
    red_list.append(i)
res=random.sample(red_list,6)
res.sort()
blue_list=[]
for i in range(1,16):
    blue_list.append(i)
blue_data=random.sample(blue_list,1)
print(res,blue_data)

67UM
[1, 8, 10, 15, 21, 22] [13]



猜你喜欢

转载自www.cnblogs.com/wuxi9864/p/9904810.html