# os.path

import os

#### os.path.abspath(path)¶

python.org/zh-cn/3/library/os.path.html#os.path.abspath" title="永久链接至目标"#### Return a normalized absolutized version of the pathname path.

#### os.path.getmtime(path)¶

Return the time of last modification of path. The return value is a floating point number giving the number of seconds since the epoch (see the time module). Raise OSError if the file does not exist or is inaccessible.

#### os.path.getctime(path)¶

Return the system's ctime which, on some systems (like Unix) is the time of the last metadata change, and, on others (like Windows), is the creation time for path. The return value is a number giving the number of seconds since the epoch (see the time module). Raise OSError if the file does not exist or is inaccessible.

#### os.path.getsize(path)¶

Return the size, in bytes, of path. Raise OSError if the file does not exist or is inaccessible.

#### os.path.isabs(path)¶

Return True if path is an absolute pathname. On Unix, that means it begins with a slash, on Windows that it begins with a (back)slash after chopping off a potential drive letter.

#### os.path.isfile(path)¶

Return True if path is an existing regular file. This follows symbolic links, so both islink() and isfile()can be true for the same path.

#### os.path.isdir(path)¶

Return True if path is an existing directory. This follows symbolic links, so both islink() and isdir() can be true for the same path.

Return True if path refers to an existing directory entry that is a symbolic link. Always False if symbolic links are not supported by the Python runtime.

#### os.path.ismount(path)¶

Return True if pathname path is a mount point: a point in a file system where a different file system has been mounted. On POSIX, the function checks whether path's parent, path/.., is on a different device than path, or whether path/.. and path point to the same i-node on the same device --- this should detect mount points for all Unix and POSIX variants. It is not able to reliably detect bind mounts on the same filesystem. On Windows, a drive letter root and a share UNC are always mount points, and for any other path GetVolumePathName is called to see if it is different from the input path.

#### os.path.join(path, *paths)¶

Join one or more path components intelligently. The return value is the concatenation of path and any members of *paths with exactly one directory separator (os.sep) following each non-empty part except the last, meaning that the result will only end in a separator if the last part is empty. If a component is an absolute path, all previous components are thrown away and joining continues from the absolute path component.

On Windows, the drive letter is not reset when an absolute path component (e.g., r'\foo') is encountered. If a component contains a drive letter, all previous components are thrown away and the drive letter is reset. Note that since there is a current directory for each drive, os.path.join("c:", "foo") represents a path relative to the current directory on drive C: (c:foo), not c:\foo.

#### os.path.normcase(path)¶

Normalize the case of a pathname. On Windows, convert all characters in the pathname to lowercase, and also convert forward slashes to backward slashes. On other operating systems, return the path unchanged. Raise a TypeError if the type of path is not str or bytes (directly or indirectly through the os.PathLikeinterface).

#### os.path.normpath(path)¶

Normalize a pathname by collapsing redundant separators and up-level references so that A//B, A/B/, A/./Band A/foo/../B all become A/B. This string manipulation may change the meaning of a path that contains symbolic links. On Windows, it converts forward slashes to backward slashes. To normalize case, use normcase().

#### os.path.realpath(path)¶

Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path (if they are supported by the operating system).

#### os.path.relpath(path, start=os.curdir)¶

Return a relative filepath to path either from the current directory or from an optional start directory. This is a path computation: the filesystem is not accessed to confirm the existence or nature of path or start.

#### os.path.samefile(path1, path2)¶

Return True if both pathname arguments refer to the same file or directory. This is determined by the device number and i-node number and raises an exception if an os.stat() call on either pathname fails.

#### os.path.sameopenfile(fp1, fp2)¶

Return True if the file descriptors fp1 and fp2 refer to the same file.

#### os.path.samestat(stat1, stat2)¶

Return True if the stat tuples stat1 and stat2 refer to the same file. These structures may have been returned by os.fstat(), os.lstat(), or os.stat(). This function implements the underlying comparison used by samefile() and sameopenfile().

#### os.path.split(path)¶

Split the pathname path into a pair, (head, tail) where tail is the last pathname component and head is everything leading up to that. The tail part will never contain a slash; if path ends in a slash, tail will be empty. If there is no slash in path, head will be empty. If path is empty, both head and tail are empty. Trailing slashes are stripped from head unless it is the root (one or more slashes only). In all cases, join(head, tail)returns a path to the same location as path (but the strings may differ). Also see the functions dirname() andbasename().

#### os.path.splitdrive(path)¶

Split the pathname path into a pair (drive, tail) where drive is either a mount point or the empty string. On systems which do not use drive specifications, drive will always be the empty string. In all cases, drive +tail will be the same as path.

On Windows, splits a pathname into drive/UNC sharepoint and relative path.

If the path contains a drive letter, drive will contain everything up to and including the colon. e.g. splitdrive("c:/dir") returns ("c:", "/dir")

If the path contains a UNC path, drive will contain the host name and share, up to but not including the fourth separator. e.g. splitdrive("//host/computer/dir") returns ("//host/computer", "/dir")

#### os.path.splitext(path)¶

Split the pathname path into a pair (root, ext) such that root + ext == path, and ext is empty or begins with a period and contains at most one period. Leading periods on the basename are ignored; splitext('.cshrc') returns ('.cshrc', '').

#### os.path.supports_unicode_filenames¶

True if arbitrary Unicode strings can be used as file names (within limitations imposed by the file system).

True如果任意Unicode字符串can be used as names（文件在文件系统的局限性imposed by the）。