Python学习:choices()的相对权重与累加权重理解
**choices(population, weights=None, *, cum_weights=None, k=1)**population:集群。weights:相对权重。cum_weights:累加权重。k:选取次数。import randomlist1 = [1, 2, 3, 4, 5]choose1 = random.choices(list1, k=5) #list1中各个元素出现次数基本持平choose2 = random.choices(list1, weights=