Python模块 random

爱被打了一巴掌 2023-09-26 23:52 103阅读 0赞

python中的random模块是内建(built-in),用来生成随机数的,常用的函数如下:
使用交互模式举例子

Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import random

#查看random模块下的函数

dir(random)
[‘BPF’, ‘LOG4’, ‘NV_MAGICCONST’, ‘RECIP_BPF’, ‘Random’, ‘SG_MAGICCONST’, ‘SystemRandom’, ‘TWOPI’, ‘WichmannHill’, ‘_BuiltinMethodType’, ‘_MethodType’, ‘all’, ‘builtins’, ‘doc’, ‘file’, ‘name’, ‘package’, ‘_acos’, ‘_ceil’, ‘_cos’, ‘_e’, ‘_exp’, ‘_hashlib’, ‘_hexlify’, ‘_inst’, ‘_log’, ‘_pi’, ‘_random’, ‘_sin’, ‘_sqrt’, ‘_test’, ‘_test_generator’, ‘_urandom’, ‘_warn’, ‘betavariate’, ‘choice’, ‘division’, ‘expov

发表评论

表情:
评论列表 (有 0 条评论,103人围观)

还没有评论,来说两句吧...

相关阅读

    相关 python random模块

    1、python标准库中的random模块重要方法: random() 返回0<=n<1之间的随机实数n; choice(seq) 从序列seq中返回随机的元