os
Native operating-system interfaces for POSIX and Windows.
POSIX paths and environment use UTF-8 with surrogateescape to preserve arbitrary
bytes; Windows uses wide-character APIs. Filesystem APIs currently accept str
paths only; fsencode() and fsdecode() additionally accept bytes and str
identity inputs, respectively.
Failures raise OSError with errno, a system diagnostic and applicable filenames
(plus winerror for Windows API failures). File-descriptor reads and writes may
transfer fewer bytes than requested. Windows permissions and available process
APIs differ from POSIX.
curdir: Literal[str] = "."
pardir: Literal[str] = ".."
extsep: Literal[str] = "."
SEEK_SET: Literal[int] = 0
SEEK_CUR: Literal[int] = 1
SEEK_END: Literal[int] = 2
F_OK: Literal[int] = 0
R_OK: Literal[int] = 4
W_OK: Literal[int] = 2
X_OK: Literal[int] = 1
O_RDONLY: Literal[int] = 0
O_WRONLY: Literal[int] = 1
O_RDWR: Literal[int] = 2
fspath(path)
fsencode(filename: str)
fsencode(filename: bytes)
fsdecode(filename: bytes)
fsdecode(filename: str)
system(cmd: str)
putenv(key: str, value: str)
Set the process environment without updating the environ mapping.
unsetenv(key: str)
Remove a process variable without updating the environ mapping.
environ = _Environ(_make_env_map(), copy=False)
getenv(key: str, default = None)
class stat_result
Fields
14
st_mode
int
st_ino
int
st_dev
int
st_nlink
int
st_uid
int
st_gid
int
st_size
int
st_atime
float
st_mtime
float
st_ctime
float
st_atime_ns
int
st_mtime_ns
int
st_ctime_ns
int
st_rdev
int
Constructors
2
Special methods
4
stat(path: str, follow_symlinks: bool = True)
stat(fd: int)
fstat(fd: int)
lstat(path: str)
open(path: str, flags: int, mode: int = 0o777)
listdir(path: str = ".")
makedirs(name: str, mode: int = 0o777, exist_ok: bool = False)
removedirs(name: str)
mkdir(path: str, mode: int = 0o777)
rmdir(path: str)
chdir(path: str)
getcwdb()
getcwd()
unlink(path: str)
remove(path: str)
rename(src: str, dst: str)
replace(src: str, dst: str)
link(src: str, dst: str)
symlink(src: str, dst: str, target_is_directory: bool = False)
readlink(path: str)
access(path: str, mode: int)
chmod(path: str, mode: int, follow_symlinks: bool = True)
getpid()
getppid()
close(fd: int)
read(fd: int, n: int)
write(fd: int, data: bytes)
lseek(fd: int, pos: int, how: int)
fsync(fd: int)
ftruncate(fd: int, length: int)
truncate(path: str, length: int)
Modules
4