2006年11月09日 星期四 11:14
lu_zi_2000 2006-11-09 -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20061109/02066f5c/attachment.html
2006年11月09日 星期四 11:25
在 06-11-9,lu_zi_2000<lu_zi_2000在163.com> 写道: > > > > ________________________________ > > lu_zi_2000 > 2006-11-09 > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > line=f.readline() if len(line)==0
2006年11月09日 星期四 11:28
°¦£¬ÎÒµÄ×÷·¨ºÍÄãÒ»Ñù£¬²»¹ý¾õµÃͦ²»Ë¬£¬¡¡fileÀïû¸öº¯ÊýÖ±½ÓÄÜÅжÏÂ𣿠lu_zi_2000 2006-11-09 ·¢¼þÈË£º Îä»á³¬ ·¢ËÍʱ¼ä£º 2006-11-09 11:26:08 ÊÕ¼þÈË£º python-chinese在lists.python.cn ³ËÍ£º Ö÷Ì⣺ Re: [python-chinese]ÔõôÅжÏÒ»¸öÎļþ¶Áµ½Á˽áβ£¬Ð»Ð» ÔÚ 06-11-9£¬lu_zi_2000 <lu_zi_2000在163.com > дµÀ£º > > > > ________________________________ > > lu_zi_2000 > 2006-11-09 > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > line=f.readline() if len(line)==0 _______________________________________________ python-chinese Post: send python-chinese在lists.python.cn Subscribe: send subscribe to python-chinese-request在lists.python.cn Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20061109/9a3c2768/attachment.htm
2006年11月09日 星期四 11:44
¿ÉÒÔÅжϰ¡¡£
СÎļþ¿ÉÒÔÒ»´ÎÐÔ¶Á³öÀ´f.read()£¬
´óÎļþÈç¹ûÊÇÒ»ÐÐÒ»Ðд¦ÀíµÄ»°¿ÉÒÔ£º
for line in file(r'c:\test'):
...
´óÎļþ²»ÄÜÒ»ÐÐÒ»Ðд¦ÀíµÄ»°¿ÉÒÔ£º
while True:
l = f.read(1024)
...
if len(l) < 1024: break
--
Best Regards,
Leo Jay
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061109/98a6bd87/attachment.html
2006年11月09日 星期四 14:55
line = f.readline()
if line == '':
break
On 11/9/06, Leo Jay <python.leojay at gmail.com> wrote:
>
> 可以判断啊。
>
> 小文件可以一次性读出来f.read(),
>
> 大文件如果是一行一行处理的话可以:
> for line in file(r'c:\test'):
> ...
>
> 大文件不能一行一行处理的话可以:
> while True:
> l = f.read(1024)
> ...
> if len(l) < 1024: break
>
> --
> Best Regards,
> Leo Jay
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20061109/aaa90081/attachment-0001.html
2006年11月12日 星期日 21:58
lu_zi_2000 写道: > > > ------------------------------------------------------------------------ > lu_zi_2000 > 2006-11-09 > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese line = f.readline() while line: do something
2006年11月14日 星期二 10:26
line = f.readline()
while line:
do something
Èç¹ûÎļþÖмäÓÐһЩ¿ÕÐУ¬Ôõô¸ã£¿
Brightman
2006-11-14
·¢¼þÈË£º david
·¢ËÍʱ¼ä£º 2006-11-12 21:59:05
ÊÕ¼þÈË£º python-chinese在lists.python.cn
³ËÍ£º
Ö÷Ì⣺ Re: [python-chinese]ÔõôÅжÏÒ»¸öÎļþ¶Áµ½Á˽áβ£¬Ð»Ð»
lu_zi_2000 дµÀ:
>
>
> ------------------------------------------------------------------------
> lu_zi_2000
> 2006-11-09
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
line = f.readline()
while line:
do something
_______________________________________________
python-chinese
Post: send python-chinese在lists.python.cn
Subscribe: send subscribe to python-chinese-request在lists.python.cn
Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061114/eb5f7e74/attachment.htm
2006年11月14日 星期二 12:06
把位置定位到文件末尾 f.seek(0,2) line=f.readline() if line: 在 06-11-14,Brightman<fenyon在126.com> 写道: > > line = f.readline() > while line: > do something > > 如果文件中间有一些空行,怎么搞? > > ________________________________ > > Brightman > 2006-11-14 > ________________________________ > > 发件人: david > 发送时间: 2006-11-12 21:59:05 > 收件人: python-chinese在lists.python.cn > 抄送: > 主题: Re: [python-chinese]怎么判断一个文件读到了结尾,谢谢 > > > lu_zi_2000 写道: > > > > > > > ------------------------------------------------------------------------ > > lu_zi_2000 > > 2006-11-09 > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > line = f.readline() > while line: > do something > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese >
2006年11月14日 星期二 15:50
readline()的返回值中包括了行结束字符\n或者\r\n 遇到文件尾,会返回空字符串对象。 -- GoogleTalk: qcxhome at gmail.com MSN: qcxhome at hotmail.com My Space: tkdchen.spaces.live.com BOINC: boinc.berkeley.edu 中国分布式计算总站: www.equn.com
Zeuux © 2025
京ICP备05028076号