Python模块 random
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
还没有评论,来说两句吧...