Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4999272
  • 博文数量: 921
  • 博客积分: 16037
  • 博客等级: 上将
  • 技术积分: 8469
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-05 02:08
文章分类

全部博文(921)

文章存档

2020年(1)

2019年(3)

2018年(3)

2017年(6)

2016年(47)

2015年(72)

2014年(25)

2013年(72)

2012年(125)

2011年(182)

2010年(42)

2009年(14)

2008年(85)

2007年(89)

2006年(155)

分类: Python/Ruby

2011-06-17 11:37:23

1,文件比较大。
  1. targetLine = "";
  2. lineNo = 0;
  3. while 1:
  4.     mLine = file.readline();
  5.     if not mLine:
  6.         break;
  7.     lineNo += 1;
  8.     if (linecount == lineNO):
  9.         targetLine = mLine;
2, 文件比较小
  1. targetLine = "";
  2. mLines = file.read();
  3. 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.
阅读(1566) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~