Pathlib

Posted on September 12, 2020


The pathlib module handles file paths with support for different operating systems.

Read text

The example below uses pathlib to read text from a file.

import pathlib

text = pathlib.Path('myfile.txt').read_text()
print(text)

Further reading


Back

Gavin Wiggins © 2020