for line in open('test.txt').readlines(): print line
for line in open('test.txt').xreadlines():print line
for line in open('test.txt'): print line
for char in open('test.txt').read(): print char
file = open('test.txt')
while 1:
char=file.read(1)
if not char:break
print char,
(p165, Learning Python 2nd edition, O'REILLY)
No comments:
Post a Comment