Skip to content

Instantly share code, notes, and snippets.

@harsh317
Created January 23, 2025 20:21
Show Gist options
  • Save harsh317/1deeab8b2a3d96734abb0580bd54aba1 to your computer and use it in GitHub Desktop.
Save harsh317/1deeab8b2a3d96734abb0580bd54aba1 to your computer and use it in GitHub Desktop.
from pathlib import Path
# Creating a file
file = Path("example.txt")
file.write_text("Hello, Pathlib!")
# Reading the file
print(file.read_text())
# Checking existence
if file.exists():
print("File exists")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment