相关疑难解决方法(0)

如何创建没有重复的随机数列表?

我试过用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)

python random

89
推荐指数
7
解决办法
13万
查看次数

标签 统计

python ×1

random ×1