Answers for "check if directory exists else make one os"

0

python check if dir exists else create

from pathlib import Path
Path("/my/directory").mkdir(parents=True, exist_ok=True)
Posted by: Guest on June-14-2021
0

os dir exists

>>> from pathlib import Path
 >>> Path('new_folder').is_dir()
 True
 >>> (Path.cwd() / 'new_folder' / 'file.txt').exists()
 False
Posted by: Guest on June-01-2021

Code answers related to "check if directory exists else make one os"

Python Answers by Framework

Browse Popular Code Answers by Language