Python: Get A List of Different Random Numbers
作者:XD / 发表: 2020年9月8日 04:12 / 更新: 2020年9月8日 04:12 / 编程笔记 / 阅读量:2391
Only one line can get a list of different random numbers (sampling without replacement). Here is the code.
import random
print(random.sample(range(1, 10), 5))
# output: [5, 8, 4, 1, 7]
相关标签