Reading a file : File Readline : File PYTHON examples


PYTHON examples » File » File Readline »

 

Reading a file




file = open('test.txt', 'rb')
while 1:
    chunk = file.read(10)        # read byte chucks
    if not chunk: break
    print chunk,

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


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo File
» File Readline