Python os.major() 方法

Python 教程 · 2019-02-04 06:29:35

概述

os.major() 方法用于从原始的设备号中提取设备major号码 (使用stat中的st_dev或者st_rdev field)。

语法

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

os.major(device)

参数

  • device -- 原始的设备号中提取设备major号码 (使用stat中的st_dev或者st_rdev field)。

返回值

返回设备major号码。

实例

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

#!/usr/bin/python
# -*- coding: UTF-8 -*-

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

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

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

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

查看所有标签

Programming Python

Programming Python

Mark Lutz / O'Reilly Media / 2006-8-30 / USD 59.99

Already the industry standard for Python users, "Programming Python" from O'Reilly just got even better. This third edition has been updated to reflect current best practices and the abundance of chan......一起来看看 《Programming Python》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具