path

代表要在存放區中使用的檔案的結構。

成員

basename

string path.basename

提供檔案基本名稱的字串。

目錄名稱

path path.dirname

這個檔案的父項目錄,如果檔案沒有父項,則為 None。 可能會傳回 None

存在

bool path.exists

如果這個路徑所表示的檔案存在,則傳回 true。

get_child

path path.get_child(*relative_paths)

傳回將這個路徑與指定相對路徑聯結後取得的路徑。

參數

參數 說明
relative_paths 必要
零或多個相對路徑字串,附加至這個路徑時會視需要加入路徑分隔符號。

readdir

list path.readdir()

這個路徑所指目錄中的項目清單。

realpath

path path.realpath

Returns the canonical path for this path by repeatedly replacing all symbolic links with their referents.