splitting a list of sentences into separate words in a list

后端 未结 4 425
失恋的感觉
失恋的感觉 2021-01-16 18:33

I have a list which consists of lines as

lines =  [\'The query complexity of estimating weighted averages.\',
     \'New bounds for the query complexity of a         


        
4条回答
  •  猫巷女王i
    2021-01-16 19:07

    You can join all lines and then use split():

    " ".join(lines).split()
    

    or you can split each line and chain:

    from itertools import chain
    list(chain(*map(str.split, lines)))
    

提交回复
热议问题