Create a directory if it does not exist in Python

by | Jul 20, 2017 | Python-example | 0 comments

Example of how to create a directory in Python:logo python

import os

directory = "/Users/diego/test/"

try:
  os.stat(directory)
 except:
  os.mkdir(directory)

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *