Home >>Python File Methods >Python File fileno() Method

Python File fileno() Method

Python File fileno() Method

Python File fileno() Method is used to return the file descriptor of the stream as a number. If the operator system does not use a file descriptor then an error will occur.

Syntax:
file.fileno()
Here is an example of Python fileno() method:

f = open("demofile.txt", "r")
print(f.fileno())

Output:
3

No Sidebar ads