处理数据时候,需要得到数据所在和行号,使用enumerate时便捷的方法:
file = open('file.txt','r')
for (num,value) in enumerate(file):
print "line num is: ",num,"content:",value
file.close()
处理数据时候,需要得到数据所在和行号,使用enumerate时便捷的方法:
file = open('file.txt','r')
for (num,value) in enumerate(file):
print "line num is: ",num,"content:",value
file.close()