Python3 File fileno() 方法

Python 3 教程 · 2019-02-06 22:26:42

概述

fileno() 方法返回一个整型的文件描述符(file descriptor FD 整型),可用于底层操作系统的 I/O 操作。

语法

fileno() 方法语法如下:

fileObject.fileno(); 

参数

返回值

返回文件描述符。

实例

以下实例演示了 fileno() 方法的使用:

#!/usr/bin/python3

# 打开文件
fo = open("codercto.txt", "wb")
print ("文件名为: ", fo.name)

fid = fo.fileno()
print ("文件描述符为: ", fid)

# 关闭文件
fo.close()

以上实例输出结果为:

文件名为:  codercto.txt
文件描述符为:  3

点击查看所有 Python 3 教程 文章: https://www.codercto.com/courses/l/10.html

查看所有标签

Transcending CSS

Transcending CSS

Andy Clarke、Molly E. Holzschlag / New Riders / November 15, 2006 / $49.99

As the Web evolves to incorporate new standards and the latest browsers offer new possibilities for creative design, the art of creating Web sites is also changing. Few Web designers are experienced p......一起来看看 《Transcending CSS》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具