Computer Science
To read the next line of the file from a file object fobj, we use:
- fobj.read(2)
- fobj.read()
- fobj.readline()
- fobj.readlines()
Python Data Handling
2 Likes
Answer
fobj.readline()
Reason — The syntax to read a line in a file is <filehandle>.readline()
. Hence according to this syntax fobj.readline() is correct format.
Answered By
1 Like
Related Questions
To read the entire contents of the file as a string from a file object fobj, the command should be:
- fobj.read(2)
- fobj.read()
- fobj.readline()
- fobj.readlines()
What will be the output of the following snippet?
f = None for i in range(5): with open("data.txt", "w") as f: if i > 2: break print(f.closed)
- True
- False
- None
- Error
To read the remaining lines of the file from a file object fobj, we use:
- fobj.read(2)
- fobj.read()
- fobj readline()
- fobj.readlines()
The readlines() method returns:
- String
- A list of integers
- A list of single characters
- A list of strings