Python os.pathconf () -Methode
Python OS Datei / Verzeichnis - Methoden
Umriss
os.pathconf () Methode gibt eine offene Dateisystemkonfigurationsinformationen.
Verfügbar unter Unix-Plattformen.
Grammatik
fpathconf () -Methode Syntax lautet wie folgt:
os.fpathconf(fd, name)
Parameter
Name - der Dateideskriptor
Name - Wert Retrieval - System - Konfiguration, kann es eine Reihe von definierten Systemwerte, diese Namen in vielen Standards (POSIX.1, Unix 95, Unix 98 angegeben sein , und andere).Einige Plattformen definieren zusätzliche Namen. Diese Namen sind im Hauptbetriebssystem auf pathconf_names Wörterbuch. Für nicht-Konfigurationsvariablen pathconf_names, eine Zahl als Namen vorbei, ist es auch akzeptabel.
Rückgabewert
Gibt Systeminformationsdatei.
Beispiele
Das folgende Beispiel zeigt fpathconf () Art der Nutzung:
#!/usr/bin/python # -*- coding: UTF-8 -*- 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 "关闭文件成功!!"
Das obige Programm Ausgabe lautet:
关闭文件成功!!