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
Domain-Driven Design
Eric Evans / Addison-Wesley Professional / 2003-8-30 / USD 74.99
"Eric Evans has written a fantastic book on how you can make the design of your software match your mental model of the problem domain you are addressing. "His book is very compatible with XP. It is n......一起来看看 《Domain-Driven Design》 这本书的介绍吧!