Is there a simple way in Python to generate a random number in a range excluding some subset of numbers in that range?
For example, I know that you can generate a random number between 0 and 9 with:
from random import randint
randint(0,9)
What if I have a list, e.g. exclude=[2,5,7]
, that I don't want to be returned?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…