我在python中有一个类似于:
的数组编辑:对不起,数据如下所示:
1. [array([[[23, 2]]]), array([[[21, 2]],
[[21, 3]],
[[21, 4]],
[[22, 4]],
[[23, 4]],
[[22, 4]],
[[21, 3]]])]
2. [array([[[28, 26]],
[[28, 27]],
[[28, 28]],
[[28, 29]],
[[28, 30]],
[[29, 30]],
[[30, 30]],
[[31, 30]],
[[31, 29]],
[[31, 28]],
[[31, 27]],
[[30, 26]],
[[29, 26]]])]
And after using print array_name[0] it looks like this:
1. [[[23 2]]]
2. [[[28 26]]
[[28 27]]
[[28 28]]
[[28 29]]
[[28 30]]
[[29 30]]
[[30 30]]
[[31 30]]
[[31 29]]
[[31 28]]
[[31 27]]
[[30 26]]
[[29 26]]]
现在我只想阅读第一部分,即[23 2]和[28 26]。它是如何做到的?
列表分为多个数组。
答案 0 :(得分:1)
import numpy
l1 = [numpy.array([[[23, 2]]]), numpy.array([[[21, 2]], [[21, 3]], [[21, 4]], [[22, 4]], [[23, 4]],
[[22, 4]], [[21, 3]]])]
l2 = [numpy.array([[[28, 26]], [[28, 27]],[[28, 28]], [[28, 29]], [[28, 30]], [[29, 30]], [[30, 30]], [[31, 30]],
[[31, 29]], [[31, 28]],[[31, 27]], [[30, 26]],[[29, 26]]])]
print l1[0] # -> [[[23 2]]]
print l2[0][0] # -> [[28 26]]