我是 Python 的初学者,我正在做这个项目,我有一个包含 7 列数字的文本文件。我需要编写一个程序来提取第 1、6 和 7 列的数据,并将它们打印在列中,而这些数据仅在列中。这是我到目前为止所做的,但似乎有问题。有人可以指出我吗?
import sys
import os
import re
GC11 = 'NGC4697'
base_dirname = '/projects/XRB_Web/abcadmus/499/Lists/'
Luminositylist = base_dirname + GC11 + '_final_list.txt'
try:
file = open(Luminositylist, 'r')
except IOError:
print 'Cannot open: '+Luminositylist
source = [ ]
luminosity = [ ]
luminosityerr = [ ]
for line in file:
point = line.split()
a = source.append(int((point[0])))
b = luminosity.append(float((point[5])))
c = luminosityerr.append(float((point[6])))
print a, b, c