【发布时间】:2017-05-11 23:33:28
【问题描述】:
我有一个像这样的多维数组:
[["asdf","bmnl", "123","456,"0","999","1234","3456"],["qwer","tyui","789","657,"122","9","673","1"]]
但是,在多维数组中,每个数组只需要最后6项,不需要前两项。如何从多维数组中的每个数组中删除前两条数据,使其看起来像:
[["123","456,"0","999","1234","3456"],["789","657,"122","9","673","1"]]
到目前为止,我已经这样做了:
list1 = []
list2 = []
for row in rows:
list1.append(row[0].split(',')) #to put the split list into the top i i.e. [["asdf","bmnl", "123","456,"0","999","1234","3456"]["qwer","tyui","789","657,"122","9","673","1"]]
for i in list1:
for index in len(list1):
if index >=2:
list2.append(index) #this does not work and causes errors
我该如何解决这个问题,所以输出将是:
[["123","456,"0","999","1234","3456"],["789","657,"122","9","673","1"]]
谢谢
【问题讨论】:
标签: python arrays multidimensional-array append