YouTip LogoYouTip

Python3 Os Major

# Python3.x Python3 os.major() Method [![Image 3: Python3 OS File/Directory Methods](#) Python3 OS File/Directory Methods](#) * * * ### Overview The os.major() method is used to extract the device major number from the raw device number (using the st_dev or st_rdev field from stat). ### Syntax The syntax for the **major()** method is as follows: os.major(device) ### Parameters * **device** -- The raw device number from which to extract the device major number (using the st_dev or st_rdev field from stat). ### Return Value Returns the device major number. ### Example The following example demonstrates the usage of the major() method: #!/usr/bin/python3import 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) The output of executing the above program is: Major device number : 0Minor device number : 103 [![Image 4: Python3 OS File/Directory Methods](#) Python3 OS File/Directory Methods](#)
← Python3 Os MakedirsPython3 Os Major β†’