python列表到换行符分隔值 [英] python list to newline separated value

查看:863
本文介绍了python列表到换行符分隔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我试图在pylon中获取数据以在jQuery自动完成中使用, 我用于自动完成的库文件需要这种格式


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

在python中,我有这种格式的数据

and in python i have data in this format

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

如何将该列表转换为上面的列表.

How do i convert this list to the above one.


我试图将这些用于自动竞争,而我使用的是塔架,其中对服务器的查询以这种格式返回列表


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/此库除外

abc 
pqr
xyz

我尝试使用

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

,但它会像这样在Firebug中返回数据.

but it returns data in firebug like this.

'asd\ndad\nweq'

我希望它位于

abc
pqr
xyz

任何帮助将不胜感激,因为我是PHP开发人员,这是我第一次尝试用python做代码.

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

恶作剧

推荐答案

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

但是,这与JSON有什么关系??

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

这篇关于python列表到换行符分隔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆