random.sample(population, k)

本文涉及的产品
智能开放搜索 OpenSearch行业算法版,1GB 20LCU 1个月
实时计算 Flink 版,5000CU*H 3个月
实时数仓Hologres,5000CU*H 100GB 3个月
简介: random.sample(population, k)

random.sample(population, k): 从指定序列中随机选择k个元素作为一个新列表返回

import random
numbers = [1, 2, 3, 4, 5]
selected_numbers = random.sample(numbers, 3)
print(selected_numbers)


相关文章
45Echarts - 柱状图(World Total Population)
45Echarts - 柱状图(World Total Population)
55 0
|
7月前
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
83 0
|
7月前
【Simulink】报错:Size mismatch (size [2 x 1] ~= size [1 x 1]). The size to the left is the size of the l
【Simulink】报错:Size mismatch (size [2 x 1] ~= size [1 x 1]). The size to the left is the size of the l
|
4月前
|
Python
module 'numpy' has no attribute 'int'.
module 'numpy' has no attribute 'int'.
165 0
INT_MIN,max函数和accumulate函数
INT_MIN,max函数和accumulate函数
|
JSON 数据格式
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
538 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
ValueError: Sample larger than population or is negative
ValueError: Sample larger than population or is negative
205 0
|
数据可视化
Paraview: Calculate Derivatives of 3-D Unstructured Dataset
关注九天学者微信公众号(扫码关注)第一时间获取技术贴更新! Paraview 是一款基于VTK的、开源的、跨平台的科学数据可视化软件,其三维显示和后处理功能非常强大。
2817 0