描述
方法fpathconf()返回與打開文件相關的係統配置信息。此變量與 unix 係統調用非常相似fpathconf()並接受類似的論點。
用法
以下是語法fpathconf()方法 -
os.fpathconf(fd, name)
參數
fd− 這是要為其返回係統配置信息的文件描述符。
name- 指定要檢索的配置值;它可能是一個字符串,它是定義的係統值的名稱;這些名稱在許多標準(POSIX.1、Unix 95、Unix 98 等)中都有規定。主機操作係統已知的名稱在os.pathconf_names字典。
返回值
此方法返回與打開文件相關的係統配置信息。
示例
下麵的例子展示了 fpathconf() 方法的用法。
#!/usr/bin/python3
import os, sys
# Open a file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )
print ("%s" % os.pathconf_names)
# Now get maximum number of links to the file.
no = os.fpathconf(fd, 'PC_LINK_MAX')
print ("Maximum number of links to the file.:%d" % no)
# Now get maximum length of a filename
no = os.fpathconf(fd, 'PC_NAME_MAX')
print ("Maximum length of a filename:%d" % no)
# Close opened file
os.close( fd)
print ("Closed the file successfully!!")
結果
當我們運行上述程序時,它會產生以下結果 -
{'PC_MAX_INPUT':2, 'PC_VDISABLE':8, 'PC_SYNC_IO':9, 'PC_SOCK_MAXBUF':12, 'PC_NAME_MAX':3, 'PC_MAX_CANON':1, 'PC_PRIO_IO':11, 'PC_CHOWN_RESTRICTED':6, 'PC_ASYNC_IO':10, 'PC_NO_TRUNC':7, 'PC_FILESIZEBITS':13, 'PC_LINK_MAX':0, 'PC_PIPE_BUF':5, 'PC_PATH_MAX':4} Maximum number of links to the file.:127 Maximum length of a filename:255 Closed the file successfully!!
相關用法
- Python 3 os.fstatvfs()用法及代碼示例
- Python 3 os.fdopen()用法及代碼示例
- Python 3 os.fdatasync()用法及代碼示例
- Python 3 os.fchmod()用法及代碼示例
- Python 3 os.fchown()用法及代碼示例
- Python 3 os.fsync()用法及代碼示例
- Python 3 os.fchdir()用法及代碼示例
- Python 3 os.fstat()用法及代碼示例
- Python 3 os.ftruncate()用法及代碼示例
- Python 3 os.minor()用法及代碼示例
- Python 3 os.close()用法及代碼示例
- Python 3 os.unlink()用法及代碼示例
- Python 3 os.major()用法及代碼示例
- Python 3 os.rmdir()用法及代碼示例
- Python 3 os.isatty()用法及代碼示例
- Python 3 os.rename()用法及代碼示例
- Python 3 os.walk()用法及代碼示例
- Python 3 os.renames()用法及代碼示例
- Python 3 os.makedirs()用法及代碼示例
- Python 3 os.utime()用法及代碼示例
注:本文由純淨天空篩選整理自 Python 3 - os.fpathconf() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。