ID EN
OS

replace

Python 3.11

Rename the file or directory src to dst. If dst is a non-empty directory, OSError will be raised. If dst exists and is a file, it will be replaced silently if the user has permission. The operation may fail if src and dst are on different filesystems. If successful, the renaming will be an atomic operation (this is a POSIX requirement).

Syntax

PYTHON
os.replace(src, dst, *, src_dir_fd=None, dst_dir_fd=None)

See Also

OSError paths relative to directory descriptors auditing event path-like object