#从一列表中,生成不重复的随机值
#算法实现
import random
total = 100
li = [i for i in range(total)]
res = []
num = 20
for i in range(num):
t = random.randint(i,total-1)
res.append(li[t])
li[t], li[i] = li[i], li[t]
print res
#python 已经实现这样的方法
print random.sample(li, num)