Function Details: readline

Description


Read until newline or EOF and return a single line of text.


Extended Description


The readline() method reads a single line from the file stream. A line is defined as a sequence of characters terminated by a newline ('\n') or EOF. If a size argument is provided, it reads at most size characters.


Function Signature



Module: io

Class: TextIOWrapper

Parameters



Parameter List


  • size: int

Return


Returns a string containing the line read. Returns an empty string if EOF is hit immediately.


Return Type


str

Output

Explanation

This example demonstrates the basic usage of readline(). It reads and prints the first line of the file.