To read 4th line from text file, which of the following statement is true?
1 point
dt = f,readlines(); print(dt[3])
dt=f.read(4) ; print(dt[3])
dt=f.readline(4) ; print(dt[3])
All Of These
Answers
Answered by
0
To read 4th line from text file,
dt = f.readlines();print(dt[3])
Explanation:
The readline () function is used to read a text line.
Answered by
0
- Each line is being returned as a string.
- We have noticed \n at the end of each line.
- This is a line return character which indicates the end of a line.
- f.readlines() actually reads in the whole file and splits it into a list of lines.
- So for large files, this can be of memory intensive.
Therefore, to read the 4th line from a text file, we use the method
dt = f.readlines(); print(dt[3])
Similar questions