1,文件比较大。
- targetLine = "";
- lineNo = 0;
- while 1:
- mLine = file.readline();
- if not mLine:
- break;
- lineNo += 1;
- if (linecount == lineNO):
- targetLine = mLine;
2, 文件比较小
- targetLine = "";
- mLines = file.read();
- targetLine = mLines[-1];
filelineno( )
Return the line number in the current file. Before the first line has been read, returns 0. After the last line of the last file has been read, returns the line number of that line within the file.
阅读(1614) | 评论(0) | 转发(0) |