Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从txt文件中提取python_Python - Fatal编程技术网

从txt文件中提取python

从txt文件中提取python,python,Python,我从txt.file中提取了行,由于注释的原因跳过了前几行。完成此操作后,我有一组列表。如何仅获取第一个索引的值并将其附加到新列表中 ['364.00', '0.000', '0.000', '364.00', '28.00', '28.00', '0.00', '0.00'] ['450.00','0.000','360.000','450.00','28.00','28.00','0.00','0.00'] ['590.00','0.000','360.000','590.00','28.

我从txt.file中提取了行,由于注释的原因跳过了前几行。完成此操作后,我有一组列表。如何仅获取第一个索引的值并将其附加到新列表中

['364.00', '0.000', '0.000', '364.00', '28.00', '28.00', '0.00', '0.00']
['450.00','0.000','360.000','450.00','28.00','28.00','0.00','0.00']
['590.00','0.000','360.000','590.00','28.00','28.00','0.00','0.00']

谢谢你的帮助

你所说的“列表组”是什么意思?对于列表列表,可以这样做:

lists = [['450.00', '0.000', '360.000', '450.00', '28.00', '28.00', '0.00', '0.00'],
['590.00', '0.000', '360.000', '590.00', '28.00', '28.00', '0.00', '0.00']]

first_entries = [i[0] for i in lists]

print(first_entries)
输出:
['450.00'、'590.00']

到目前为止您尝试了什么?