Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 File fileno() Method

Python3 File fileno() Method

Python3 File Methods Python3 File methods


Overview

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

Syntax

The fileno() method syntax is as follows:


fileObject.fileno(); 

Parameters

Return Value

Returns the file descriptor.

Example

The following example shows how to use the fileno() method:


#!/usr/bin/python3

# Open file
fo = open("runoob.txt", "wb")
print ("文件名为: ", fo.name)

fid = fo.fileno()
print ("文件描述符为: ", fid)

# Close file
fo.close()

The output of the above example is:


文件名为:  runoob.txt
文件描述符为:  3

Python3 File Methods Python3 File methods