Python3 File fileno() Method
Overview
fileno()The method returns an integer file descriptor (file descriptor FD integer), which can be used for low-level operating system I/O operations.
Syntax
The syntax for 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/python3
# 打开文件
fo = open("example.txt", "wb")
print ("文件名为: ", fo.name)
fid = fo.fileno()
print ("文件描述符为: ", fid)
# 关闭文件
fo.close()
The output of the above example is:
文件名为: example.txt 文件描述符为: 3
Other Extensions
Python3 File Methods