Table of Contents

Python - File System Path

About

File System - Path in Python

Path definition can be found path-like-object

Library

Os.path

3/library/os.path.html

To create a path:

os.path.join("output","log.txt")

Pathlib

Object-oriented filesystem paths

from pathlib import Path
Path('setup.py') # a subclass of PurePath
PurePath('/etc', '/usr', 'lib64') # generic, it creates either a PurePosixPath or a PureWindowsPath
PurePosixPath('/etc') # non-Windows filesystem paths
PureWindowsPath('c:/Windows', 'd:bar') # Windows filesystem paths