Python

Python Menu

Definition

The read() method returns the specified number of bytes from the file. Default is -1 which means the whole file.

Syntax

file.read()

Parameters

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

Examples:

f = open("myFile.txt", "r")
print(f.read())
f = open("myFile.txt", "r")
print(f.read(33))*

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods