python list to newline separated value

后端 未结 5 2101
孤独总比滥情好
孤独总比滥情好 2020-12-11 11:54


Im trying to get data in pylon to use in jquery autocomplete, the librarary i\'m using for autocomplete it requires this format

abc
pqr
xyz
         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 12:18

    Er I'm not sure what exactly you want, but if you need to print that you could do

    for l in data:
        print l[0]
    

    or if you want to make it a flat list, you could do something like

    map(lambda x: x[0], a)
    

    or if you even just want a single string with newlines, you could do something like

    "\n".join(map(lambda x: x[0], a))
    

    Dunno if that helped at all, but wish you luck

提交回复
热议问题