PyDocs

Nav

File and Directory Access

Path.write_text

pathlib

method of Path · Added in 3.5 (source)
  • Path.write_text(data, encoding=None, errors=None, newline=None)
Open the file in text mode, write to it, and close the file.
Changed in 3.10
  • 3.10: 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.write_text
0 Notes
No notes for Path.write_text