Skip to content

Instantly share code, notes, and snippets.

@pFransozi
Created July 13, 2023 01:09
Show Gist options
  • Save pFransozi/0297b6839849ef0f38faab07f53bd8c5 to your computer and use it in GitHub Desktop.
Save pFransozi/0297b6839849ef0f38faab07f53bd8c5 to your computer and use it in GitHub Desktop.
py create new dir and file
from pathlib import Path
folder = Path("new_dir")
folder.mkdir(exist_ok=True)
file = folder / "new_file.txt"
file.write_text("Hello, world")
file.read_text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment