我试过用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);
Run Code Online (Sandbox Code Playgroud)