different methods to read a python file
f = open("harish", "r")
print(f.readline()) # 1 method...it will show the content line by line
print(f.readlines()) # 2 method...it will show the whole content not line by line
for line in f: # 3 method
print(line, end="")
content = f.read() # 4 method
print(content)
Comments
Post a Comment