A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/python/os_statvfs.htm below:

Python os.statvfs() Method

Python os.statvfs() Method

The Python method os.statvfs() perform a statvfs system call on the given path. It is used to retrieve the status of a file system.

When we call the os.statvfs(), it returns a statvfs_result object. This object contains various attributes that represent the status of the file system.

Syntax

Syntax of Python os.statvfs() method is as follows −

os.statvfs(path)
Parameters

The Python os.statvfs() method accepts a single parameter −

Return Value

The Python os.statvfs() methods returns a statvfs_result object that contains the below attributes −

Example

The following example shows the usage of statvfs() method. Here, we are displaying statvfs information of the given file.

import os, sys

# showing statvfs information of file "a1.py"
stinfo = os.statvfs("atty.py")

print (stinfo)

When we run above program, it produces following result −

os.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=6276673,
 f_bfree=2780772, f_bavail=2455601, f_files=1605632, f_ffree=1374428,
 f_favail=1374428, f_flag=4096, f_namemax=255)
Example

In this example, we are accessing various information related to filesystem using the attributes of statvfs_result object.

import os

# file
fpath = "atty.py"

# Retrieve filesystem info
statsinfo = os.statvfs(fpath)

# Display filesystem info
print(f"File system block size: {statsinfo.f_bsize}")
print(f"Fragment size: {statsinfo.f_frsize}")
print(f"Total number of blocks: {statsinfo.f_blocks}")
print(f"Total number of free blocks: {statsinfo.f_bfree}")

On executing the above program, it will display the following output −

File system block size: 4096
Fragment size: 4096
Total number of blocks: 6276673
Total number of free blocks: 2780767

python_files_io.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4