Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

jquery - python list to newline separated value


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

and in python i have data in this format

[["abc"], ["pqr"],["xyz"]

How do i convert this list to the above one.

Edit:
I trying to use these for a autocompete and i'm using pylons, in which the query to the server return list in this format

    [["abc"], ["pqr"],["xyz"]

http://jquery.bassistance.de/autocomplete/demo/ this library except remote call in

abc 
pqr
xyz

i tried to use

"
".join(item[0] for item in my_list)

but it returns data in firebug like this.

'asd
dad
weq'

i want it to be in

abc
pqr
xyz

any help would be appreciated as i'm a PHP developer this is first time i'm trying to do code in python.

thnaks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
"
".join(item[0] for item in my_list)

However, what's this got to do with JSON...?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...