首页 > 代码库 > random python

random python

random.randrange(stop)random.randrange(startstop[, step])

Return a randomly selected element from range(start, stop, step). This is equivalent to choice(range(start, stop, step)), but doesn’t actually build a range object.

>>> import random>>> print random.randrange(1,10+1)

 

random.randint(ab)

Return a random integer N such that <= <= b.