fileno()方法返回所使用的底層實現(xiàn),要求從操作系統(tǒng)I/O操作的整數(shù)文件描述符。
語法
以下是fileno()方法的語法:
fileObject.fileno();
參數(shù)
返回值
此方法返回整數(shù)文件描述符。
例子
下面的例子顯示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()當(dāng)我們運行上面的程序,它會產(chǎn)生以下結(jié)果:
Name of the file: foo.txtFile Descriptor: 3
新聞熱點
疑難解答
圖片精選