'''
readline()通过函数的调用,可以一行一行的显示。
如果不用函数来调用,readline()永远只显示一行
'''
kayson@kayson-virtual-machine:~$ cat def1.py
#! /usr/bin/python
current_file = open('file1')
def p_a(lie,f):
print lie,f.readline()
p_a(1,current_file)
p_a(1,current_file)
p_a(1,current_file)
输出结果
kayson@kayson-virtual-machine:~$ python def1.py
1 llline1
1 dddline2
1 sssline3
kayson@kayson-virtual-machine:~$ cat file1
llline1
ddline2
ccline3
eeline4
阅读(1119) | 评论(0) | 转发(0) |