如何列出特定列的列表
我有一个列表,如下所示。如何仅列出输出的第三列(以0.002147开头的列表)这就是我的输出的方式
I have a list of linelists file as below.how do i make a list of only the 3rd column of the output(the one starting with 0.002147)this is how my output is
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设线词看起来像这样:
第三列
您可以使用
col3list = [line.split(“ \ t”)[2]的
[l] ,它可以使您 ['col31 ','col32'] 。
基于您提供的图像,尚不清楚列是否被选项卡或多个空格分开。如果分离器是空格,则需要更改拆分函数的参数。
与您的问题类似的事情也已经回答了在这里。
通常,我建议使用python库
Assuming linelists looks something like this:
you can select the third column with
col3list = [line.split("\t")[2] for line in l]
which gives you
['col31', 'col32']
.Based on the image you provided, it is not clear if the columns are separated by a tab or multiple spaces. If the separators are spaces, you would need to change the argument of the split function.
Something similar to your question was also already answered here.
In general I would recommend loading files with the python library pandas, which can handle all kinds of data loading and selection tasks for you.