描述
方法makedev()由主設備號和次設備號組成一個原始設備號。
用法
以下是語法makedev()方法 -
os.makedev(major, minor)
參數
major− 這是主設備號。
minor- 這是次要設備號。
返回值
此方法返回設備編號。
示例
下麵的例子展示了 makedev() 方法的用法。
#!/usr/bin/python3
import os, sys
path = "/var/www/html/foo.txt"
# Now get the touple
info = os.lstat(path)
# Get major and minor device number
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)
# Make a device number
dev_num = os.makedev(major_dnum, minor_dnum)
print ("Device Number:", dev_num)
結果
當我們運行上述程序時,它會產生以下結果 -
Major Device Number:0 Minor Device Number:103 Device Number:103
相關用法
- Python 3 os.makedirs()用法及代碼示例
- Python 3 os.major()用法及代碼示例
- Python 3 os.minor()用法及代碼示例
- Python 3 os.mknod()用法及代碼示例
- Python 3 os.mkdir()用法及代碼示例
- Python 3 os.mkfifo()用法及代碼示例
- Python 3 os.fstatvfs()用法及代碼示例
- Python 3 os.close()用法及代碼示例
- Python 3 os.unlink()用法及代碼示例
- Python 3 os.rmdir()用法及代碼示例
- Python 3 os.fdopen()用法及代碼示例
- Python 3 os.fdatasync()用法及代碼示例
- Python 3 os.isatty()用法及代碼示例
- Python 3 os.rename()用法及代碼示例
- Python 3 os.walk()用法及代碼示例
- Python 3 os.renames()用法及代碼示例
- Python 3 os.utime()用法及代碼示例
- Python 3 os.tcgetpgrp()用法及代碼示例
- Python 3 os.statvfs()用法及代碼示例
- Python 3 os.lchown()用法及代碼示例
注:本文由純淨天空篩選整理自 Python 3 - os.makedev() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。