Latest web development tutorials

Python os.statvfs () method

Python File (File) method Python OS file / directory methods


Outline

os.statvfs () method returns the file that contains the information for the file descriptor fd of the file system.

grammar

statvfs () method syntax is as follows:

os.statvfs([path])

parameter

  • path - file path.

return value

Back structure:

  • f_bsize: file system block size

  • f_frsize: sub-stack size

  • f_blocks: The total number of file system data blocks

  • f_bfree: Available blocks

  • f_bavail: number of blocks available in non-root user

  • f_files: file structure Total points

  • f_ffree: available file nodes

  • f_favail: a non-root nodes available files

  • f_fsid: file system identifier ID

  • f_flag: Mount mark

  • f_namemax: maximum file size

Examples

The following example demonstrates statvfs () method of use:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os, sys

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

print stinfo

The above program output 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)

Python File (File) method Python OS file / directory methods