कौन सा कथन फ़ाइल से एक पंक्ति लौटाएगा (फ़ाइल ऑब्जेक्ट 'f‟ है)?
Which statement will return one line from a file (file object is 'f‟) ?
A
f.readlines()
B
f.readline()
C
f.read()
D
f.line()
Explanation
- When you call
f.readline(), it reads the next line from the file objectf. It reads until it reaches the end of the line, including the newline character (\n), but it does not return the newline character at the end of the string. - If the end of the file is reached,
f.readline()returns an empty string ('').
Correct Answer: B) f.readline()