无涯教程-OS File - os.fstatvfs(fd)函数

45 阅读1分钟

Python方法fstatvfs()返回有关包含与文件描述符fd关联的文件系统的信息。

    os.fstatvfs(fd) - 语法

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

    os.fstatvfs(fd) - 返回值

    此方法返回有关包含关联文件的文件系统的信息。

    os.fstatvfs(fd) - 示例

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

    #!/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.fstatvfs(fd)

    print "File Info :", info

    # Now get maximum filename length print "Maximum filename length :%d" % info.f_namemax:

    # Now get free blocks print "Free blocks :%d" % info.f_bfree

    # Close opened file os.close( fd)

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

    File Info : (4096, 4096, 2621440L, 1113266L, 1113266L, 
                 8929602L, 8764252L, 8764252L, 0, 255)
    Maximum filename length :255
    Free blocks :1113266

    参考链接

    www.learnfk.com/python/os-f…