File函数 中的 file.fileno()函数

首页 / Python2入门教程 / File函数 中的 file.fileno()函数

Python file fileno()返回整数文件描述符,基础实现使用该描述符从操作系统请求I/O操作。

file.fileno() - 语法

fileObject.fileno(); 

file.fileno() - 返回值

此方法返回整数文件描述符。

file.fileno() - 示例

以下示例显示了fileno()方法的用法。

无涯教程网

#!/usr/bin/python

# 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()

当无涯教程运行上面的程序时,它产生以下输出-

链接:https://www.learnfk.comhttps://www.learnfk.com/python/file-fileno.html

来源:LearnFk无涯教程网

Name of the file:  foo.txt
File Descriptor:  3

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

赵成的运维体系管理课 -〔赵成〕

硅谷产品实战36讲 -〔曲晓音〕

从0开始学架构 -〔李运华〕

TensorFlow 2项目进阶实战 -〔彭靖田〕

OAuth 2.0实战课 -〔王新栋〕

操作系统实战45讲 -〔彭东〕

说透区块链 -〔自游〕

eBPF核心技术与实战 -〔倪朋飞〕

给程序员的写作课 -〔高磊〕

好记忆不如烂笔头。留下您的足迹吧 :)