"[:,]"列表切片python,这是什么意思? [英] "[:,]" list slicing python, what does it mean?

查看:173
本文介绍了"[:,]"列表切片python,这是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读一些代码,看到了" list[:,i] for i in range(0,list))......"

我对在那里的逗号感到迷惑,:,,由于您无法使用Google标点符号,因此google无法提供答案.

任何帮助都将不胜感激!

解决方案

您正在查看 numpy 多维数组切片. /p>

逗号标记一个元组,将其读取为[(:, i)]numpy数组将其解释为:首先要使用:端到端(所有行)切片的维,然后是每行选择一个列.

请参见numpy教程中的索引,切片和迭代.

I'm reading some code and I see " list[:,i] for i in range(0,list))......"

I am mystified as to what comma is doing in there, :, and google offers no answers as you cant google punctuation.

Any help greatly appreciated!

解决方案

You are looking at numpy multidimensional array slicing.

The comma marks a tuple, read it as [(:, i)], which numpy arrays interpret as: first dimension to be sliced end-to-end (all rows) with :, then for each row, i selects one column.

See Indexing, Slicing and Iterating in the numpy tutorial.

这篇关于"[:,]"列表切片python,这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆