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

Python File fileno() method

Python File fileno() method

Python File methods Python 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/python

# -*- coding: UTF-8 -*-



# 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

Python File methods Python File methods