YouTip LogoYouTip

Python3 Os Major

# Python3 os.major() Method ## Python3 os.major() Method ### Overview The `os.major()` method is used to extract the major device number from a raw device number (using the `st_dev` or `st_rdev` field from `stat`). ### Syntax The syntax for the `major()` method is as follows: ```python os.major(device) ### Parameters * **device** -- The raw device number from which to extract the major device number (using the `st_dev` or `st_rdev` field from `stat`). ### Return Value Returns the major device number. ### Example The following example demonstrates the use of the `major()` method: ```python #!/usr/bin/python3 import os, sys path = "/var/www/html/foo.txt" # Get the tuple info = os.lstat(path) # Get 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 will produce the following output: Major Device Number : 0 Minor Device Number : 103
← Python3 Os MajorPython3 Os Lseek β†’