python生成10个随机数


当前第2页 返回上一页

随机整数:

1

2

>>> import random

>>> random.randint(0,99)

21

随机选取0到100间的偶数:

1

2

>>> import random

>>> random.randrange(0, 101, 2)

42

随机浮点数:

1

2

>>> import random

>>> random.random()

0.85415370477785668

1

>>> random.uniform(1, 10)

5.4221167969800881

随机字符:

1

2

>>> import random

>>> random.choice('abcdefg&#%^*f')

'd'

以上就是python生成10个随机数的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

如何使用Python中range()方法?

Python多进程的用法示例(代码)

Python人工智能难吗

Python如何遍历字符串

Python print 按逗号或空格分隔的方法

怎么利用Python赚钱

Python 创建空的list,以及append用法讲解

Python3.7下怎么安装matplotlib

了解Python 中日志异步发送到远程服务器

基于Python如何实现计算两组数据p值

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...