|
Size: 4315
Comment:
|
← Revision 10 as of 2023-10-11 19:43:17 ⇥
Size: 4315
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 14: | Line 14: |
| ||`abspath()` ||see [[Python/PathLib#Absolute|Path.absolute]] || ||`basename()` ||see [[Python/PathLib#Name|Path.name]] || |
||`abspath()` ||see [[Python/PathLib#Methods|Path.absolute]] || ||`basename()` ||see [[Python/PathLib#Methods|Path.name]] || |
| Line 18: | Line 18: |
| ||`dirname()` ||see [[Python/PathLib#Parent|Path.parent]] || ||`exists()` ||see [[Python/PathLib#Exists|Path.exists]] || ||`expanduser()` ||see [[Python/PathLib#ExpandUser|Path.expanduser]] and [[Python/PathLib#Home|Path.home]] || |
||`dirname()` ||see [[Python/PathLib#Methods|Path.parent]] || ||`exists()` ||see [[Python/PathLib#Methods|Path.exists]] || ||`expanduser()` ||see [[Python/PathLib#Methods|Path.expanduser]] and [[Python/PathLib#ClassMethods|Path.home]] || |
| Line 26: | Line 26: |
| ||`isabs()` ||see [[Python/PathLib#Is_Absolute|Path.is_absolute]] || ||`isdir()` ||see [[Python/PathLib#Is_Dir|Path.is_dir]] || ||`isfile()` ||see [[Python/PathLib#Is_File|Path.is_file]] || ||`islink()` ||see [[Python/PathLib#Is_SymLink|Path.is_symlink]] || ||`join()` ||see [[Python/PathLib#JoinPath|Path.joinpath]] || |
||`isabs()` ||see [[Python/PathLib#Methods|Path.is_absolute]] || ||`isdir()` ||see [[Python/PathLib#Methods|Path.is_dir]] || ||`isfile()` ||see [[Python/PathLib#Methods|Path.is_file]] || ||`islink()` ||see [[Python/PathLib#Methods|Path.is_symlink]] || ||`join()` ||see [[Python/PathLib#Methods|Path.joinpath]] || |
| Line 33: | Line 33: |
| ||`realpath()` ||see [[Python/PathLib#Resolve|Path.resolve]] || ||`relpath()` ||see [[Python/PathLib#Relative_To|Path.relative_to]] || ||`samefile()` ||see [[Python/PathLib#SameFile|Path.samefile]] || |
||`realpath()` ||see [[Python/PathLib#Methods|Path.resolve]] || ||`relpath()` ||see [[Python/PathLib#Methods|Path.relative_to]] || ||`samefile()` ||see [[Python/PathLib#Methods|Path.samefile]] || |
| Line 40: | Line 40: |
| ||`splitext()` ||see [[Python/PathLib#Stem|Path.stem]] and [[Python/PathLib#Suffix|Path.suffix]] || | ||`splitext()` ||see [[Python/PathLib#Methods|Path.stem]] and [[Python/PathLib#Methods|Path.suffix]] || |
Python Os Path
os.path is a module providing filesystem APIs.
Contents
Functions
Function |
Example |
abspath() |
see Path.absolute |
basename() |
see Path.name |
commonpath() |
commonpath('/usr/lib', '/usr/local') returns '/usr' |
commonprefix() |
commonprefix('/usr/lib', '/usr/local') returns '/usr/l' |
dirname() |
see Path.parent |
exists() |
see Path.exists |
expanduser() |
see Path.expanduser and Path.home |
expandvars() |
variable references like $name and ${name} (and %name% on Windows) are replaced with variable values if defined |
getatime() |
last access time of a file, as a float representing seconds since the epoch |
getctime() |
last metadata change time (Unix) or creation time (Windows) of a file |
getmtime() |
last modification time of a file |
getsize() |
size of a file |
isabs() |
see Path.is_absolute |
isdir() |
see Path.is_dir |
isfile() |
see Path.is_file |
islink() |
see Path.is_symlink |
join() |
see Path.joinpath |
normcase() |
on Windows only, push letters to lowercase and replace forward slashes (/) with backslashes (\) |
normpath() |
collapse redundant separators and up-level references |
realpath() |
see Path.resolve |
relpath() |
see Path.relative_to |
samefile() |
see Path.samefile |
sameopenfile() |
test if two open file objects are the same |
samestat() |
test if two os.stat_result instances are the same |
split() |
split('/usr/bin') returns ('/usr/', 'bin', ); split('/usr/') returns ('/usr/', '', ) |
splitdrive() |
on Windows only, split the drive letter or UNC host name off |
splitext() |
see Path.stem and Path.suffix |
See also
Python os.path module documentation
Python Module of the Day article for os.path
