Python os.major() Method
Example
Print the device major number:
#Import os Library
import os
# Get the raw device number
device = os.stat("file.txt").st_dev
# Print the device major number
print("Major Device Number:", os.major(device))
Definition and Usage
The os.major()
method returns the device major number from raw device number.
Raw device number is usually st_dev
or st_rdev
field from stat.
st_dev
identifies the device on which the file resides and st_rdev
represent type of device.
Syntax
os.major(device)
Parameter Values
Parameter | Description |
---|---|
device | Required. Raw Device number |
Technical Details
Return Value: | An int value, representing the device major number
|
---|---|
Python Version: | 2.3 |