乱序小程序
import random
group = list(range(0,26))
print(group)
random.shuffle(group)
print(group)
输出
乱序前:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
乱序后:[10, 6, 8, 9, 12, 0, 24, 1, 2, 18, 11, 14, 4, 16, 15, 22, 7, 13, 17, 5, 20, 25, 23, 3, 19, 21]
随机抽人小程序
import random
data = []
# 或者内定data =["员工1","员工2"]
for line in open("file","r"):
data.append(line)
rs =random.sample(data,6)
print(rs)
image.png
网友评论