Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีดึง Major Device Number จาก Raw Device Number ใน Python

os.major(device) ดึง major device number จาก raw device number (มักมาจาก st_dev หรือ st_rdev ของ stat)

ตัวอย่าง

import os, sys
path = "/var/www/html/foo.txt"
info = os.lstat(path)
major_dnum = os.major(info.st_dev)
print("Major Device Number:", major_dnum)

ผลลัพธ์

Major Device Number: 0