Skip to content

Instantly share code, notes, and snippets.

View pFransozi's full-sized avatar
🎯
Focusing

Philipe Fransozi pFransozi

🎯
Focusing
View GitHub Profile
@pFransozi
pFransozi / gist:0297b6839849ef0f38faab07f53bd8c5
Created July 13, 2023 01:09
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()
@pFransozi
pFransozi / gist:2d480a3c3d48ce0ad3f4b902d6b818d4
Created July 13, 2023 01:08
py create new dir and file
import os
if not os.path.exists("new_dir"):
os.makedirs("new_dir")
file = os.path.join("new_dir", "new_file.txt")
with open(file, "w") as f:
f.write("Hello, world")