Python File fileno() Method
Overview
fileno()The method returns an integer file descriptor (FD integer), which can be used for low-level I/O operations in the operating system.
Syntax
The syntax of the fileno() method is as follows:
fileObject.fileno();
Parameters
None
Return Value
Returns the file descriptor.
Example
The following example demonstrates the use of the fileno() method:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# 打开文件
fo = open("example.txt", "wb")
print "文件名为: ", fo.name
fid = fo.fileno()
print "文件描述符为: ", fid
# 关闭文件
fo.close()
The output of the above example is:
文件名为: example.txt 文件描述符为: 3Other Extensions
Python File Methods