python去不重复的随机数

1 import random
2 
3 x = int(input('请输入题库:'))
4 y = int(input('请输入次数:'))
5 sep = list(range(1,x+1))
6 a = random.sample(sep,y)
7 a.sort()
8 print(a)

 

posted @ 2017-10-08 16:20  今生A  阅读(1658)  评论(0)    收藏  举报