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,
相關文章
相關標籤/搜索