Python檔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
上一篇:
Python檔對象方法
下一篇:
Python os模組方法