English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic Python tutorial

Python flow control

Fonction en Python

Types de données en Python

Python file operations

Python objects and classes

Python date and time

Advanced knowledge of Python

Python reference manual

Python file fileno() usage and examples

Python File (File) methods

Overview

fileno() The method returns an integer file descriptor (file descriptor FD integer) that can be used for low-level operating system I/O operation.

Syntax

fileno() method syntax is as follows:

fileObject.fileno();

Parameter

  • None

Return value

Return the file descriptor.

Example

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

# Open the file
fo = open("w3codebox.txt, "wb")
print("File name: ", fo.name)
fid = fo.fileno()
print("File descriptor is: ", fid)
# Close the file
fo.close()

The output result of the above example is:

File name:  w3codebox.txt
File descriptor is:  3

Python File (File) methods