Easy Tutorial
❮ Python Assert Python Func Repr ❯

Python3 File fileno() Method

Python3 File Methods


Overview

The fileno() method returns an integer file descriptor, which can be used for low-level operating system I/O operations.

Syntax

The syntax for the fileno() method is as follows:

fileObject.fileno();

Parameters

-

None

Return Value

Returns the file descriptor.

Example

The following example demonstrates the use of the fileno() method:

#!/usr/bin/python3

# Open file
fo = open("tutorialpro.txt", "wb")
print("File name: ", fo.name)

fid = fo.fileno()
print("File descriptor: ", fid)

# Close file
fo.close()

The output of the above example is:

File name:  tutorialpro.txt
File descriptor:  3

Python3 File Methods

❮ Python Assert Python Func Repr ❯