Generate a list, shuffle that and pop from it each time the function is called:
import random
def CreatePass(_numbers=[]):
if not _numbers:
_numbers[:] = range(1000, 10000)
random.shuffle(_numbers)
return str(_numbers.pop())
Note that this re-generates the _numbers
list once you've run out, but then you've used up all 8999 possible numbers and would have to accept repetitions anyway.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…