Python3 os.statvfs() Method

Python3 OS 文件/目录方法Python3 OS File/Directory Methods


Overview

The os.statvfs() method is used to return information about the file system containing the file described by the file descriptor fd.

Syntax

statvfs()The method syntax is as follows:

os.statvfs([path])

Parameters

  • path-- file path.

Return Value

Returned structure:

  • f_bsize:File system block size

  • f_frsize:Fragment size

  • f_blocks:Total number of data blocks in the file system

  • f_bfree:Number of available blocks

  • f_bavail:Number of blocks available to non-super users

  • f_files:Total number of file nodes

  • f_ffree:Number of available file nodes

  • f_favail:Number of available file nodes for non-super users

  • f_fsid:File system ID

  • f_flag:Mount flags

  • f_namemax:Maximum file length

Example

The following example demonstrates the use of the statvfs() method:

#!/usr/bin/python3

import os, sys

# 显示 "a1.py" 文件的 statvfs 信息
stinfo = os.statvfs('a1.py')

print (stinfo)

The output of the above program is:

posix.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=1909350L, f_bfree=1491513L,
f_bavail=1394521L, f_files=971520L, f_ffree=883302L, f_fvail=883302L, f_flag=0,
f_namemax=255)

Python3 OS 文件/目录方法Python3 OS File/Directory Methods

Other Extensions