File Path Manipulation with os.path in Python


Work with file paths in a platform-independent way.

Source Code

import os

# Join parts of a file path
path = os.path.join("folder", "subfolder", "file.txt")
print(path)

# Get the absolute path
print(os.path.abspath(path))
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments