Python-如何创建无重复的随机数列表?
发布于 2021-02-02 23:14:06
我尝试使用random.randint(0, 100)
,但一些数字相同。有没有一种方法/模块来创建唯一的随机数列表?
def getScores():
# open files to read and write
f1 = open("page.txt", "r");
p1 = open("pgRes.txt", "a");
gScores = [];
bScores = [];
yScores = [];
# run 50 tests of 40 random queries to implement "bootstrapping" method
for i in range(50):
# get 40 random queries from the 50
lines = random.sample(f1.readlines(), 40);
关注者
0
被浏览
65
1 个回答