Question : if dir not exist mkdir python
Answered by : nice-newt-l4zhl7y4dx1g
import os
if not os.path.exists('my_folder'):
os.makedirs('my_folder')
Source : https://www.tutorialspoint.com/How-can-I-create-a-directory-if-it-does-not-exist-using-Python | Last Update : Fri, 17 Apr 20
Question : python check if file exists
Answered by : duco
import os
os.path.exists("file.txt") # Or folder, will return true or false
Source : https://www.guru99.com/python-check-if-file-exists.html | Last Update : Fri, 21 Feb 20
Question : python make directory if not exists
Answered by : exuberant-earthworm-6lirblpv1qhj
try: os.makedirs("path/to/directory")
except FileExistsError: # directory already exists pass
Source : https://stackoverflow.com/questions/273192/how-can-i-safely-create-a-nested-directory | Last Update : Sat, 14 Nov 20
Question : mkdir if not exists python
Answered by : yellowed-yacare-qnc1i7of89qk
from pathlib import Path
Path("/my/directory").mkdir(parents=True, exist_ok=True)
Source : https://stackoverflow.com/questions/273192/how-can-i-safely-create-a-nested-directory-in-python | Last Update : Mon, 22 Nov 21