PyDocs

Nav

File and Directory Access

Path.read_text

pathlib

method of Path · Added in 3.5 (source)
  • Path.read_text(encoding=None, errors=None, newline=None)
Open the file in text mode, read it, and close the file.
Changed in 3.13
  • 3.13: The newline parameter was added.
1 Example
>>> p = Path('my_text_file')
>>> p.write_text('Text file contents')
18
>>> p.read_text()
'Text file contents'
from the Python docs
See Also
No see-alsos for pathlib/Path.read_text
0 Notes
No notes for Path.read_text