Python Glossary Русский

all Python 3osfunction

os.unlink

os — removal

Remove a file (a synonym of os.remove).

Syntax

os.unlink(...)

It does the same as os.remove: the name unlink comes from Unix, where deleting a file means removing a link to it; the data disappears once no links and no open descriptors remain. In pathlib the same action is Path.unlink(missing_ok=True), which does not raise for a missing file.

Examples

import os
open('temp.txt', 'w').close()
os.unlink('temp.txt')
print(os.path.exists('temp.txt'))   # → False

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy