1 # 产生一个0-10的随机序列,元素不能重复 2 def randSeq(): 3 import random; 4 randSequence=random.sample(range(0,10),10); 5 return randSequence;
运行结果:
1 >>> randSequence 2 [0, 6, 4, 9, 3, 5, 1, 8, 2, 7] 3 >>>
时间: 2024-10-10 09:03:24
1 # 产生一个0-10的随机序列,元素不能重复 2 def randSeq(): 3 import random; 4 randSequence=random.sample(range(0,10),10); 5 return randSequence;
运行结果:
1 >>> randSequence 2 [0, 6, 4, 9, 3, 5, 1, 8, 2, 7] 3 >>>