How to iterate through a list of lists in python?

前端 未结 7 1970
陌清茗
陌清茗 2020-12-09 11:27

I have a list of lists like this.

documents = [[\'Human machine interface for lab abc computer applications\',\'4\'],
             [\'A survey of user opinio         


        
7条回答
  •  被撕碎了的回忆
    2020-12-09 11:54

    As explained in http://docs.python.org/library/operator.html#operator.itemgetter, You can also try with

    from operator import itemgetter
    documents = map(itemgetter(0), documents)
    

    that should be faster than using an explicit loop.

提交回复
热议问题