我如何访问列表中的列表? 例如
data = [ [[list([1,2,3]), list([0,1])]], [[list([4,5,6]), list([1,1])]] ]
输出数据应为
output = [[1,2,3],[4,5,6]]
答案 0 :(得分:0)
按索引访问各个列表,如下所示。
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]
答案 1 :(得分:0)
这就是我做的
>>> 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]]