python随机数模拟

`#随机数
import random
red = range(1,36,1)
red_target_list=[]
i=1
while i< 6:
    red_ran_index=random.randint(0,34)   #0-34
    red_target_list_value=red[red_ran_index]
    # print(red_target_list_value)
    if red_target_list_value not in red_target_list:
        red_target_list.append(red_target_list_value)
    else:
        i-=1
    i+=1
print(red_target_list)
blue = range(1,13,1)
blue_target_list=[]
j=1
while j < 3:
    blue_ran_index=random.randint(0,11)
    blue_target_list_value=red[blue_ran_index]
    if blue_target_list_value not in blue_target_list:
        blue_target_list.append(blue_target_list_value)
    else:
        j-=1
    j+=1
print(blue_target_list)
print(red_target_list,blue_target_list)`````````
posted @ 2022-11-29 17:36  diablo-427  阅读(34)  评论(0编辑  收藏  举报