1) readline 每次读一行,返回序列
2) readlines 一次全部读出,返回序列
3) numpy 的genfromtxt,返回为np的矩阵格式
import numpy as np f=file('sample.txt','r') ll=np.genfromtxt('sample.txt',dtype=None) lline=f.readlines() print ll,lline for line in lline print line singleline=f.readline() source=line.rstrip()# 去除换行符 name = source.split(' ')[0] ra = source.split(' ')[1] dec = source.split(' ')[2] ........