gpt4 book ai didi

python - 如何获取目录或驱动器的文件系统?

转载 作者:太空宇宙 更新时间:2023-11-03 14:24:12 25 4
gpt4 key购买 nike

如何在 Python 中确定给定路径或驱动器是否格式化为 EXT4、EXT3、EXT2、FAT32、NTFS 或其他格式?

最佳答案

psutil是一个跨平台的包,可以 identify partition types :

>>> psutil.disk_partitions()
[sdiskpart(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,nosuid'),
sdiskpart(device='/dev/sda2', mountpoint='/home', fstype='ext4', opts='rw')]

警告:在 linux 上,fstype 可能报告为 ext4ntfs,但在 Windows 上,fstype 仅限于 "removable", "fixed"", "remote", "cdrom", "unmounted"or "ramdisk".

关于python - 如何获取目录或驱动器的文件系统?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23081440/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com