Modern File Handling With Pathlib

Mon 10 August 2026
from pathlib import Path

file_path = Path("example.txt")

file_path.write_text("Using pathlib module")
print(file_path.read_text())

s(file_path.exists())
print(file_path.parent)
Using pathlib module
True
.

Score: 5

Category: chapter12_file_handling