Web Analytics

Python file.read() Method

File Method โ€ข Read

The read() method returns the specified number of bytes from the file.

Default is -1 which means the whole file.

Syntax

file.read(size)

Parameters

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

Return Value

The content of the file.

Example

Using the read() method:

Output
Click Run to execute your code

Related Functions