增加一个判断就行!
import random
a = list(range(1,40))
index = 22 #指定不被抽到的随机数
flag = True
while flag:
空格b = random.sample(a,7)
空格if index not in b: flag = False
print(b[0:7])
最好将随机数放进数组,然后在数组里随机随即一个数对应数组就去、除去出一个。
增加一个指定数列表,与随机数比对
c = [ x,y,z]
b= random.sample(a,7)
if not b in c:
pass