First page Back Continue Last page Overview Graphics

Reading „Line by Line“ / char by char

fobj = open("yellow_snow.txt")

for line in fobj:

print(line.rstrip())

fobj.close()

and now we read character by character:

from __future__ import print_function

fileHandle = open("test.py","r")

char = fileHandle.read(1)

while char:

print(char,end=" ")

char = fileHandle.read(1)

fileHandle.close()