python 读取文本文件的行号及行内容

Python 读取文件时同时输出行号与行内容。spa file = open("file.txt","r") for num,value in enumerate(file): print "the nume:%s,the value is %s" %(num,value) file.close()file 若是想打印从行号1开始就把enumerate(file)改成enumerate(file,
相关文章
相关标签/搜索