Skip to content

Instantly share code, notes, and snippets.

@cr3a7ure
Forked from keithweaver/create-folder.py
Created January 8, 2019 12:08
Show Gist options
  • Save cr3a7ure/020c06375ed83412717234b147c434d8 to your computer and use it in GitHub Desktop.
Save cr3a7ure/020c06375ed83412717234b147c434d8 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