ID EN
Pathlib

open

Python 3.11

Open the file pointed to by the path, like the built-in open() function does:

Syntax

PYTHON
Path.open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)

Examples

Example 1
PYTHON
>>> p = Path('setup.py')
>>> with p.open() as f:
...     f.readline()
...
'!/usr/bin/env python3\n'

See Also

open()