python list to newline separated value

后端 未结 5 2100
孤独总比滥情好
孤独总比滥情好 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:36

    I am not exactly sure what you want, but you may try:

    nested_list = [ ["abc"], ["pqr"], ["xyz"] ]
    data = "\n".join( (item[0] for item in nested_list) )
    

    This will convert your list of lists into a string separated by newline characters.

提交回复
热议问题