Sorting and Grouping Nested Lists in Python

后端 未结 8 1614
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 20:05

I have the following data structure (a list of lists)

[
 [\'4\', \'21\', \'1\', \'14\', \'2008-10-24 15:42:58\'], 
 [\'3\', \'22\', \'4\', \'2somename\', \'2         


        
8条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 20:52

    For part (2), with x being your array, I think you want,

    [y for y in x if y[3] == '2somename']
    

    Which will return a list of just your data lists that have a fourth value being '2somename'... Although it seems Kamil is giving you the best advice with going for SQL...

提交回复
热议问题