Readline function to read one line a time, Readlines Function to get list of lines.

# Readline function to read one line a time

# f = open("24. Tutorial.txt", "rt")
# print(f.readline())
# f.close()
# Output :
# We are on a mission to transform and Optimize World with Indian Technologies.

# f = open("24. Tutorial.txt", "rt")
# print(f.readline())
# print(f.readline())
# print(f.readline())
# f.close()
# Output : (new line in file already + one line gap due to print's by default backslash)
# We are on a mission to transform and Optimize World with Indian Technologies.

# We will work hard.

# We will win.


########## Readlines Function to get list of lines.

# f = open("24. Tutorial.txt", "rt")
# print(f.readlines())
# f.close()
# Output :
# ['We are on a mission to transform and Optimize World with Indian Technologies.\n',
# 'We will work hard.\n', 'We will win.']

######################################################


# d = open("raaz", "rt")
# print(d.readlines())
# print(d.readline())
# print(d.readline())
# print(d.readline())
# matter = d.read()
# for line in d:
# print(line, end="")
# print(matter)
# matter = d.read(20)
# print(matter)
# d.close()

Comments

Popular posts from this blog

MAP FILTER AND REDUCE FUNCTION IN PYTHON

Writing Appending to a File

Recursions: Recursive Vs Iterative Approach