The Path Object
Build paths the modern way.
Modern Paths with pathlib
The pathlib module represents filesystem paths as objects instead of plain strings. A Path object knows how to join, split, and inspect itself, replacing many scattered os.path functions.
Creating a Path
Import Path and construct one from a string. Printing it shows the path text.
from pathlib import Path
p = Path('folder/file.txt')
print(p)