- 论坛徽章:
- 0
|
| randint(self, a, b)
| Return random integer in range [a, b], including both end points.
|
| randrange(self, start, stop=None, step=1, int=<type 'int'>, default=None, maxwidth=9007199254740992L)
| 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.
| Do not supply the 'int', 'default', and 'maxwidth' arguments.
貌似是末尾的点是否被随机到的问题,如果是randint的话,a和b都有可能被随机到,但是randrange就不会随机到b
PS:你的问题应该可以这么写- a[random.randrange(0,len(a))]
复制代码 |
|