fr = open(filename)
for line in fr.readlines():
if line.startswith("#"):
continue
else:
## do something with line
## could use fr.readlines()[1:] from second line
import linecache
content_list = linecache.getlines(filename)[1:] ## Here using getlines
fourth_line = linecache.getline(filename, 4) ## Here using getline
## the above method is simpler.python读取特定的行
原创
©著作权归作者所有:来自51CTO博客作者qizok的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:R语言移除缺失值 NA.RM
下一篇:numpy中矩阵转置
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
















