python获得磁盘剩余空间 statvfs,pythonstatvfs,[Python]代码


[Python]代码

    [mps@mps-1 ~]$ python      Python 2.4.3 (#1, Sep  3 2009, 15:37:37)      [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2      Type "help", "copyright", "credits" or "license" for more information.      >>> import os      >>> import statvfs      >>> vfs=os.statvfs("/home")      >>> vfs      (4096, 4096, 70959944, 70058799, 66396080, 73269248, 73234981, 73234981, 0, 255)      >>> dir(statvfs)      ['F_BAVAIL', 'F_BFREE', 'F_BLOCKS', 'F_BSIZE', 'F_FAVAIL', 'F_FFREE', 'F_FILES', 'F_FLAG', 'F_FRSIZE', 'F_NAMEMAX', '__builtins__', '__doc__', '__file__', '__name__']      >>> available=vfs[statvfs.F_BAVAIL]*vfs[statvfs.F_BSIZE]/(1024*1024*1024)      >>> available      253      >>> capacity=vfs[statvfs.F_BLOCKS]*vfs[statvfs.F_BSIZE]/(1024*1024*1024)      >>> capacity      270      >>> used=capacity-available      >>> used      17      >>>  

评论关闭