python标准模块:random

Functions for integers

random.randrange(stop)
random.randrange(start, stop[, step])
相当于random.choice(range(start, stop, step))

Functions for sequences

random.choice(seq)
random.choices(population, weights=None, *, cum_weights=None, k=1)
Return a k sized list of elements chosen from the population with replacement. 返回值可能出现相同的元素
random.shuffle(x[, random])
Shuffle the sequence x in place.没有返回值
random.sample(population, k)
Return a k length list of unique elements chosen from the population sequence or set

3 Real-valued distributions
random.random()
[0.0, 1.0)
random.uniform(a, b)
Return a random floating point number N
random.gauss(mu, sigma)
mu is the mean, and sigma is the standard deviation.

猜你喜欢

转载自blog.csdn.net/syqnyue/article/details/87930491
今日推荐