Big array with random numbers with python
问题 I need to generate a big array (or list) with random numbers ( 10⁵ numbers) . I was trying like that: vet = random.sample(range(10),100000) But when I try to run : vet = random.sample(range(10),10000) File "/usr/lib/python2.7/random.py", line 320, in sample raise ValueError("sample larger than population") ValueError: sample larger than population Any solution? tkns 回答1: What you want is [random.random() for _ in xrange(100000)] From the random module documentation: random.sample(population,