Python的makedev()
方法从主要和次要设备编号组成原始设备编号。
语法
以下是makedev()
方法的语法 -
os.makedev(major, minor)
参数
- major - 这是主要设备号。
- minor - 这是次要设备号。
返回值
- 此方法返回设备号。
示例
以下示例显示了makedev()
方法的用法。
#!/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)
# Make a device number
dev_num = os.makedev(major_dnum, minor_dnum)
print ("Device Number :", dev_num)
执行上面代码后,将得到以下结果 -
Major Device Number : 0
Minor Device Number : 103
Device Number : 103
上一篇:
Python os模块方法
下一篇:
Python异常处理