Python3 os.makedev() 方法

Python 3 教程 · 2019-02-07 14:57:14

概述

os.makedev() 方法用于以major和minor设备号组成一个原始设备号。

语法

makedev()方法语法格式如下:

os.makedev(major, minor)

参数

  • major -- Major 设备号。

  • minor -- inor 设备号。

返回值

返回设备号。

实例

以下实例演示了 makedev() 方法的使用:

#!/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)

执行以上程序输出结果为:

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

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

Learning Web Design

Learning Web Design

Jennifer Niederst Robbins / O'Reilly Media / 2007-6-15 / USD 44.99

Since the last edition of this book appeared three years ago, there has been a major climate change with regard to web standards. Designers are no longer using (X)HTML as a design tool, but as a means......一起来看看 《Learning Web Design》 这本书的介绍吧!

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具