Skip to content

Instantly share code, notes, and snippets.

@icarrr
Forked from keithweaver/create-folder.py
Created November 7, 2019 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icarrr/a89c3ec4fbd4ab96546504b4183c5a87 to your computer and use it in GitHub Desktop.
Save icarrr/a89c3ec4fbd4ab96546504b4183c5a87 to your computer and use it in GitHub Desktop.
Create a folder with Python
import os
def createFolder(directory):
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print ('Error: Creating directory. ' + directory)
# Example
createFolder('./data/')
# Creates a folder in the current directory called data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment