Python3 os.fstatvfs() 方法
Python 3 教程
· 2019-02-07 11:28:13
概述
os.fstatvfs() 方法用于返回包含文件描述符fd的文件的文件系统的信息,类似 statvfs()。
Unix上可用。
fstatvfs 方法返回的结构:
f_bsize: 文件系统块大小
f_frsize: 分栈大小
f_blocks: 文件系统数据块总数
f_bfree: 可用块数
f_bavail:非超级用户可获取的块数
f_files: 文件结点总数
f_ffree: 可用文件结点数
f_favail: 非超级用户的可用文件结点数
f_fsid: 文件系统标识 ID
f_flag: 挂载标记
f_namemax: 最大文件长度
语法
fstatvfs()方法语法格式如下:
os.fstatvfs(fd)
参数
fd -- 文件的描述符。
返回值
返回包含文件描述符fd的文件的文件系统的信息。
实例
以下实例演示了 fstatvfs() 方法的使用:
#!/usr/bin/python3
import os, sys
# 打开文件
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )
# 获取元组
info = os.fstatvfs(fd)
print ("文件信息 :", info)
# 获取文件名最大长度
print ("文件名最大长度 :%d" % info.f_namemax)
# 获取可用块数
print ("可用块数 :%d" % info.f_bfree)
# 关闭文件
os.close( fd)
执行以上程序输出结果为:
文件信息 : (4096, 4096, 2621440L, 1113266L, 1113266L,
8929602L, 8764252L, 8764252L, 0, 255)
文件名最大长度 :255
可用块数 :1113266
点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html
Powerful
Patty McCord / Missionday / 2018-1-25
Named by The Washington Post as one of the 11 Leadership Books to Read in 2018 When it comes to recruiting, motivating, and creating great teams, Patty McCord says most companies have it all wrong. Mc......一起来看看 《Powerful》 这本书的介绍吧!