Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 os.fstatvfs() Method

Python3 os.fstatvfs() Method

Python3 OS File/Directory Methods Python3 OS File/Directory Methods


Overview

The os.fstatvfs() method returns information about the file system of the file containing the file descriptor fd; equivalent to statvfs() in Python 3.3..

Available on Unix.

The structure returned by the fstatvfs method:

Syntax

The **fstatvfs()** method syntax is as follows:


os.fstatvfs(fd)

Parameters

Return Value

Returns information about the file system of the file containing the file descriptor fd.

Example

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


#!/usr/bin/python3

import os, sys

# Open file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )

# Get tuple
info = os.fstatvfs(fd)

print ("文件信息 :", info)

# Get maximum filename length
print ("文件名最大长度 :%d" % info.f_namemax)

# Get available blocks
print ("可用块数 :%d" % info.f_bfree)

# Close file
os.close( fd)

The output of the above program is:


文件信息 : (4096, 4096, 2621440L, 1113266L, 1113266L, 
             8929602L, 8764252L, 8764252L, 0, 255)
文件名最大长度 :255
可用块数 :1113266

Python3 OS File/Directory Methods Python3 OS File/Directory Methods