python的random模块的几个实用函数

1. randrange(a,b,step)

从a到b的以step为间隔的序列中随机选出一个整数

This fixes the problem with randint() which includes the
endpoint; in Python this is usually not what you want.

2. random()

返回0到1之间的随机浮点数

3.uniform(a,b)

返回a,b之间的浮点数

4.randint(a,b)

返回a,b之间的整数,包括b

5.choice(sequence)

从数列sequence中随机获取一个数

6.shuffle(sequence)

打乱数列

7.sample(sequence)

 从序列seq中选择n个随机且独立的元素;

8.choice(sequence)

从数列中随机选择一个元素

你可能感兴趣的:(python语法)