OS File 中的 os.fstat(fd)函数

首页 / Python2入门教程 / OS File 中的 os.fstat(fd)函数

Python方法fstat()返回有关与FD关联的文件的信息。

    os.fstat(fd) - 语法

    os.fstat(fd)
    • fd  -  这是要返回其系统信息的文件描述符。

    os.fstat(fd) - 返回值

    此方法返回有关与FD关联的文件的信息。

    os.fstat(fd) - 示例

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

    无涯教程网

    #!/usr/bin/python
    
    import os, sys
    
    # Open a file
    fd=os.open( "foo.txt", os.O_RDWR|os.O_CREAT )
    
    # Now get  the touple
    info=os.fstat(fd)
    
    print "File Info :", info
    
    # Now get uid of the file
    print "UID of the file :%d" % info.st_uid
    
    # Now get gid of the file
    print "GID of the file :%d" % info.st_gid
    
    # Close opened file
    os.close( fd)

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

    File Info : (33261, 3753776L, 103L, 1, 0, 0, 
                102L, 1238783197, 1238786767, 1238786767)
    UID of the file :0
    GID of the file :0

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

    技术教程推荐

    技术领导力实战笔记 -〔TGO鲲鹏会〕

    TensorFlow快速入门与实战 -〔彭靖田〕

    Go语言从入门到实战 -〔蔡超〕

    深入浅出计算机组成原理 -〔徐文浩〕

    Netty源码剖析与实战 -〔傅健〕

    微信小程序全栈开发实战 -〔李艺〕

    软件设计之美 -〔郑晔〕

    MySQL 必知必会 -〔朱晓峰〕

    React Hooks 核心原理与实战 -〔王沛〕

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