fileno()方法返回所使用的底層實現,要求從操作系統I/O操作的整數文件描述符。
語法
以下是fileno()方法的語法:
fileObject.fileno();
參數
NA返回值
此方法返回整數文件描述符。
例子
下面的例子顯示fileno()方法的使用。
#!/usr/bin/python# Open a filefo = open("foo.txt", "wb")print "Name of the file: ", fo.namefid = fo.fileno()print "File Descriptor: ", fid# Close opend filefo.close()
當我們運行上面的程序,它會產生以下結果:
Name of the file: foo.txtFile Descriptor: 3
新聞熱點
疑難解答