Python模块random

xiaoxiao2021-02-28  94

1、参考链接

https://docs.python.org/3/library/random.html

Python版本:3.5.3

2.常用函数

(1).随机整数

print random.randint(5, 30)

(2).随机浮点数

0到1的随机浮点数 print (random.random()) 10到20的随机浮点数 print (random.uniform(10, 20))

(3).随机选取0到200间的偶数

print(random.randrange(0, 201, 2))

(4).随机字符

print(random.choice('ASDFGHJKL;'!@#$%^')) print(random.choice ( ['运维架构师', '程序猿', '程序媛', 'DBA', 'DEVOPS'] ))
转载请注明原文地址: https://www.6miu.com/read-50743.html

最新回复(0)