os.major(device)
device -- 這是一個原始裝置號(通常是從stat的st_dev或st_rdev欄位)。
#!/usr/bin/python3 import os, sys path = "/var/www/html/foo.txt" # Now get the touple info = os.lstat(path) # Get major and minor device number major_dnum = os.major(info.st_dev) minor_dnum = os.minor(info.st_dev) print ("Major Device Number :", major_dnum) print ("Minor Device Number :", minor_dnum)
Major Device Number : 0 Minor Device Number : 103