Python File fileno() 方法

Python 教程 · 2019-02-03 14:14:12

概述

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

语法

fileno() 方法语法如下:

fileObject.fileno(); 

参数

返回值

返回文件描述符。

实例

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

#!/usr/bin/python
# -*- coding: UTF-8 -*-

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

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

# 关闭文件
fo.close()

以上实例输出结果为:

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

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

查看所有标签

The Haskell School of Expression

The Haskell School of Expression

Paul Hudak / Cambridge University Press / 2000-01 / USD 95.00

Functional programming is a style of programming that emphasizes the use of functions (in contrast to object-oriented programming, which emphasizes the use of objects). It has become popular in recen......一起来看看 《The Haskell School of Expression》 这本书的介绍吧!

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具

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

HSV CMYK互换工具