Python3 os.pathconf () method
Python3 OS file / directory methods
Outline
os.pathconf () method returns an open file system configuration information.
Available under Unix platforms.
grammar
fpathconf () method syntax is as follows:
os.fpathconf(fd, name)
parameter
name - the file descriptor
name - value retrieval system configuration, it may be a string of defined system values, these names specified in many standards (POSIX.1, Unix 95, Unix 98 , and others).Some platforms define additional names. These names are in the main operating system on pathconf_names dictionary. For not pathconf_names configuration variables, passing a number as a name, it is also acceptable.
return value
Returns system information file.
Examples
The following example demonstrates fpathconf () method of use:
#!/usr/bin/python3 import os, sys # 打开文件 fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT ) print ("%s" % os.pathconf_names) # 获取文件最大连接数 no = os.fpathconf(fd, 'PC_LINK_MAX') print ("Maximum number of links to the file. :%d" % no) # 获取文件名最大长度 no = os.fpathconf(fd, 'PC_NAME_MAX') print ("Maximum length of a filename :%d" % no) # 关闭文件 os.close( fd) print ("关闭文件成功!!")
The above program output is:
关闭文件成功!!