135-18219792

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

python3学习之random

import random

print(random.random())  #随机取值
print(random.randint(1,4))  #随机从1到4去一个整数,包含1和4
print(random.choice([1,2,3,4]))  #随机从列表中选一个,返回字符串
print(random.choices([1,2,3]))  #随机从列表中选一个,返回list
print(random.randrange(1,4))  #随机从1到4去一个整数,包含1和不包含4
print(random.sample([1,2,3],2))  #随机从列表中选2个,返回list
print(random.uniform(1,5))  #返回return a + (b-a) * self.random()

网站标题:python3学习之random
链接URL:http://www.kmfynas.com/article/jpjhcc.html

其他资讯

让你的专属顾问为你服务