is there any library or function that tells me the partition's type for a specific "path" in python??
or how can I accomplish that with any other approach?
thanks in advance!
How to find the file system type in python also seems relevant.
Here's what I came up with:
import subprocess
import os
def is_filesys_fat32(path):
try:
subprocess.check_call(['df', '--type=fat32', path], stdout=os.devnull)
except:
return False
return True
Assuming you're running linux (as the tag mentions), and that you're only searching for existence of the type, not getting the type (use a regex on subprocess.check_output()
using the same command?).
Okay, in my previous answer, I thought you need windows, however, I believe I found a way in Linux.
Try this:
By using subprocess on this command df -T /users/f/foo/file.txt
, you can get the results you need.
import subprocess
p = subprocess.Popen(["df -T %s"] % path, stdout=subprocess.PIPE)
out, err = p.communicate()
Sample output:
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda5 ext4 472439072 146088944 302351616 33% /
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.