Python Tutorial ( PDFDrive )

28.10.2021 Views

• st_dev: device.• st_nlink: number of hard links.• st_uid: user id of owner.• st_gid: group id of owner.• st_size: size of file, in bytes.• st_atime: time of most recent access.• st_mtime: time of most recent content modification.• st_ctime: time of most recent metadata change.Example The following example shows the usage of stat() method.# !/usr/bin/pythonimport os, sys# showing stat information of file "a2.py"statinfo = os.stat('a2.py')print statinfoLet us compile and run the above program, this will produce the following result:posix.stat_result(st_mode=33188, st_ino=3940649674337682L, st_dev=277923425L, st_nlink=1, st_uid=400, st_gid=401, st_size=335L, st_atime=1330498089, st_mtime=1330498089, st_ctime=1330498089)os.stat_float_times([newvalue]) Description The method stat_float_times() determines whether stat_result represents time stamps as float objects.Syntax Following is the syntax for stat_float_times() method:os.stat_float_times([newvalue])Parameters • newvalue -- If newvalue is True, future calls to stat() return floats, if it is False, future calls return ints. Ifnewvalue is not mentioned, it returns the current settings.Return Value This method returns true or false.Example The following example shows the usage of stat_float_times() method.# !/usr/bin/pythonimport os, sysTUTORIALS POINT Simply Easy Learning

# stat informationstatinfo = os.stat('a2.py')print statinfostatinfo = os.stat_float_times()print statinfoLet us compile and run the above program, this will produce the following result:posix.stat_result(st_mode=33188, st_ino=3940649674337682L, st_dev=277923425L,st_nlink=1, st_uid=400, st_gid=401, st_size=335L, st_atime=1330498089, st_mtime=1330498089, st_ctime=1330498089)Trueos.statvfs(path) Description The method statvfs() performs a statvfs system call on the given path.Syntax Following is the syntax for statvfs() method:os.statvfs(path)Parameters • path -- This is the path whose statvfs information is required.Return Value Here is the list of members of statvfs structure:• f_bsize: preferred file system block size.• f_frsize: fundamental file system block size.• f_blocks: total number of blocks in the filesystem.• f_bfree: total number of free blocks.• f_bavail: free blocks available to non-super user.• f_files: total number of file nodes.• f_ffree: total number of free file nodes.• f_favail: free nodes available to non-super user.• f_flag: system dependent.• f_namemax: maximum file name length.Example The following example shows the usage of statvfs() method.# !/usr/bin/pythonTUTORIALS POINT Simply Easy Learning

# stat information

statinfo = os.stat('a2.py')

print statinfo

statinfo = os.stat_float_times()

print statinfo

Let us compile and run the above program, this will produce the following result:

posix.stat_result(st_mode=33188, st_ino=3940649674337682L, st_dev=277923425L,

st_nlink=1, st_uid=400, st_gid=401, st_size=335L, st_atime=1330498089, st_mtime=13

30498089, st_ctime=1330498089)

True

os.statvfs(path)

Description

The method statvfs() performs a statvfs system call on the given path.

Syntax

Following is the syntax for statvfs() method:

os.statvfs(path)

Parameters

• path -- This is the path whose statvfs information is required.

Return Value

Here is the list of members of statvfs structure:

• f_bsize: preferred file system block size.

• f_frsize: fundamental file system block size.

• f_blocks: total number of blocks in the filesystem.

• f_bfree: total number of free blocks.

• f_bavail: free blocks available to non-super user.

• f_files: total number of file nodes.

• f_ffree: total number of free file nodes.

• f_favail: free nodes available to non-super user.

• f_flag: system dependent.

• f_namemax: maximum file name length.

Example

The following example shows the usage of statvfs() method.

# !/usr/bin/python

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!