Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 列表中的索引,其中包含python中的另一组列表_Python 3.x_Indexing - Fatal编程技术网

Python 3.x 列表中的索引,其中包含python中的另一组列表

Python 3.x 列表中的索引,其中包含python中的另一组列表,python-3.x,indexing,Python 3.x,Indexing,如何访问列表中的列表? 比如说 data = [ [[list([1,2,3]), list([0,1])]], [[list([4,5,6]), list([1,1])]] ] 输出数据应该是 output = [[1,2,3],[4,5,6]] 按索引访问以下各个列表 data[0] = [[[1, 2, 3], [0, 1]]] data[0][0] = [[1, 2, 3], [0, 1]] data[0][0][0] = [1, 2, 3] data[1][0][0] = [4,

如何访问列表中的列表? 比如说

 data = [ [[list([1,2,3]), list([0,1])]], [[list([4,5,6]), list([1,1])]] ]
输出数据应该是

output = [[1,2,3],[4,5,6]]

按索引访问以下各个列表

data[0] = [[[1, 2, 3], [0, 1]]]
data[0][0] = [[1, 2, 3], [0, 1]]
data[0][0][0] = [1, 2, 3]
data[1][0][0] = [4, 5, 6]
这就是我所做的

>>> data = [ [[list([1,2,3]), list([0,1])]], [[list([4,5,6]), list([1,1])]] ]
>>> output = list([row[0][0] for row in data])
>>> print (output)
[[1, 2, 3], [4, 5, 6]]

通过学习列表操作,而不是以其他方式。
[d[0][0]表示数据中的d]
与以前一样,具有列表理解能力。我已经找到了一种方法。