fileno()方法返回所使用的底層實現,從操作系統 I/O 操作整數檔描述符。
語法
以下是 fileno()方法的語法 -
fileObject.fileno()
參數
-
NA
返回值
這個方法返回整數檔描述符。
示例
下麵的例子顯示 fileno()方法的使用。
#!/usr/bin/python3 # Open a file fo = open("foo.txt", "wb") print ("Name of the file: ", fo.name) fid = fo.fileno() print ("File Descriptor: ", fid) # Close opend file fo.close()
當我們運行上面的程式,會產生以下結果 -
Name of the file: foo.txt File Descriptor: 3
上一篇:
Python3模組
下一篇:
Python3檔方法