"[:,]"列表切片python,这是什么意思? [英] "[:,]" list slicing python, what does it mean?
问题描述
我正在阅读一些代码,看到了" 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屋!