Python3 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/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