Python3 os.makedev() Method

Python3 OS 文件/目录方法Python3 OS File/Directory Methods


Overview

The os.makedev() method is used to compose a raw device number from the major and minor device numbers.

Syntax

makedev()The method syntax is as follows:

os.makedev(major, minor)

Parameters

  • major-- Major device number.

  • minor-- Minor device number.

Return Value

Returns the device number.

Example

The following example demonstrates the use of the makedev() method:

#!/usr/bin/python3

import os, sys

path = "/var/www/html/foo.txt"

# 获取元组
info = os.lstat(path)

# 获取 major 和 minor 设备号
major_dnum = os.major(info.st_dev)
minor_dnum = os.minor(info.st_dev)

print ("Major 设备号 :", major_dnum)
print ("Minor 设备号 :", minor_dnum)

# 生成设备号
dev_num = os.makedev(major_dnum, minor_dnum)
print ("设备号 :", dev_num)

The output of the above program is:

Major 设备号 : 0
Minor 设备号 : 103
设备号 : 103

Python3 OS 文件/目录方法Python3 OS File/Directory Methods

Other Extensions