Python File fileno() method
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
-
None
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