2024-05-19 13:09:39 发布
网友
我使用os.statvfs查找卷上的可用空间——除了查询特定路径的可用空间之外,我希望能够遍历所有卷。我目前正在研究Linux,但理想情况下我希望在Linux上返回["/", "/boot", "home"],在Windows上返回{}。在
os.statvfs
["/", "/boot", "home"]
对于Linux,解析/etc/mtab或/proc/mounts如何?或者:
/etc/mtab
/proc/mounts
import commands mount = commands.getoutput('mount -v') lines = mount.split('\n') points = map(lambda line: line.split()[2], lines) print points
对于Windows,我发现了如下内容:
还有这个:
from win32com.client import Dispatch fso = Dispatch('scripting.filesystemobject') for i in fso.Drives : print i
试试这些,也许它们能帮上忙。在
这也有助于:Is there a way to list all the available drive letters in python?
对于Linux,解析
/etc/mtab
或/proc/mounts
如何?或者:对于Windows,我发现了如下内容:
^{pr2}$还有这个:
试试这些,也许它们能帮上忙。在
这也有助于:Is there a way to list all the available drive letters in python?
相关问题 更多 >
编程相关推荐