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()方法的用法。

    链接:https://www.learnfk.comhttps://www.learnfk.com/python/os-fstat.html

    来源:LearnFk无涯教程网

    #!/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

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

    技术教程推荐

    技术管理实战36讲 -〔刘建国〕

    Android开发高手课 -〔张绍文〕

    JavaScript核心原理解析 -〔周爱民〕

    小马哥讲Spring核心编程思想 -〔小马哥〕

    NLP实战高手课 -〔王然〕

    Spark核心原理与实战 -〔王磊〕

    讲好故事 -〔涵柏〕

    超级访谈:对话毕玄 -〔毕玄〕

    AI 应用实战课 -〔黄佳〕

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