random.sample(population, k): 从指定序列中随机选择k个元素作为一个新列表返回
import random numbers = [1, 2, 3, 4, 5] selected_numbers = random.sample(numbers, 3) print(selected_numbers)
random.sample(population, k): 从指定序列中随机选择k个元素作为一个新列表返回
import random numbers = [1, 2, 3, 4, 5] selected_numbers = random.sample(numbers, 3) print(selected_numbers)