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

Popular posts from this blog

Steps taken by a compiler to execute a C program

Tokens in C

Variables and Data Types in C