import random
1 生成随机数
random 模块
random.randint()
1 产生随机整数,介于两者之间,包含两个端点
2 def randint(a, b)
3 Return random integer in range [a, b], including both end points.
random.random()
1 [0, 1) 的 随机数
2 def random()
3 random() -> x in the interval [0, 1)
random.choice()
1 非空序列中选一个随机数
2 def choice(seq)
3 Choose a random element from a non-empty sequence.
4 random.choice([1, 2, 3, 4, 5])
近期评论