从函数签名中我们可以知道:
In [7]: random.randrange? Signature: random.randrange(start, stop=None, step=1, _int=, _maxwidth=9007199254740992L) Docstring: Choose a random item from range(start, stop[, step]). This fixes the problem with randint() which includes the endpoint; in Python this is usually not what you want. File: /usr/lib/python2.7/random.py Type: instancemethod In [8]: random.uniform? Signature: random.uniform(a, b) Docstring: Get a random number in the range [a, b) or [a, b] depending on rounding. File: /usr/lib/python2.7/random.py Type: instancemethod
randrange 是从 range(start, stop[, step]) 随机挑选一个,生成的一定是 int ;
uniform 是从 [a, b) 或 [a, b] 中生成一个随机数,生成的是 float;
这两个使用场景不一样。
【相关推荐】
1.特别推荐:“php程序员工具箱”V0.1版本下载
2. Python免费视频教程
Dbsite企业网站管理系统V1.5.0 秉承"大道至简 邦达天下"的设计理念,以灵巧、简单的架构模式构建本管理系统。可根据需求可配置多种类型数据库(当前压缩包支持Access).系统是对多年企业网站设计经验的总结。特别适合于中小型企业网站建设使用。压缩包内包含通用企业网站模板一套,可以用来了解系统标签和设计网站使用。QQ技术交流群:115197646 系统特点:1.数据与页
立即学习“Python免费学习笔记(深入)”;










