Python

Python Menu

Python

Python File readline() - Definition, Syntax, Parameters, Examples

Definition

The readline() method returns one line from the file. You can also specify how many bytes from the line to return, by using the size parameter.

Syntax

file.readline(size)

Parameters

Parameter Description
size Optional. The number of bytes from the line to return. Default -1, which means the whole line.

Examples:

f = open("myFile.txt", "r")
print(f.readline())

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods