Python File fileno() 方法
概述
fileno()方法返回一個整型的文件描述符(file descriptor FD整型),可用於底層操作系統的I/O操作。
語法
fileno() 方法語法如下:
fileObject.fileno();
參數
無
返回值
返回文件描述符。
實例
以下實例演示了fileno() 方法的使用:
#!/usr/bin/python # -*- coding: UTF-8 -*- # 打开文件 fo = open("w3big.txt", "wb") print "文件名为: ", fo.name fid = fo.fileno() print "文件描述符为: ", fid # 关闭文件 fo.close()
以上實例輸出結果為:
文件名为: w3big.txt 文件描述符为: 3