How to create folder

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

from https://gist.github.com/keithweaver/562d3caa8650eefe7f84fa074e9ca949

原文地址:https://www.cnblogs.com/morganh/p/8329398.html