Easy Tutorial
❮ Python Os Remove Python Step1 ❯

Python3 os.minor() Method

Python3 OS File/Directory Methods


Overview

The os.minor() method is used to extract the device minor number from the raw device number (using the st_dev or st_rdev field from stat).

Syntax

The syntax for the minor() method is as follows:

os.minor(device)

Parameters

-

device -- The raw device (using the st_dev or st_rdev field from stat)

Return Value

Returns the device minor number.

Example

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

#!/usr/bin/python3

import os, sys

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

# Get the tuple
info = os.lstat(path)

# Get the major and minor device numbers
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)

Executing the above program outputs:

Major Device Number : 0
Minor Device Number : 103

Python3 OS File/Directory Methods

❮ Python Os Remove Python Step1 ❯